Add unittests for issue 11360.

This commit is contained in:
Ognjen Ivkovic 2013-10-25 20:24:05 -06:00
parent a563a920eb
commit 042f3d4282

View file

@ -514,11 +514,17 @@ private:
{ {
t[i] = variantArgs[i].get!T(); t[i] = variantArgs[i].get!T();
} }
static if(is(ReturnType!A == void)) static if(is(ReturnType!A == void))
{
(*zis)(t.expand);
*p = VariantN.init; // Uninitialized Variant.Uninitialized *p = VariantN.init; // Uninitialized Variant.Uninitialized
}
else else
{
*p = (*zis)(t.expand); *p = (*zis)(t.expand);
} }
}
break; break;
default: assert(false); default: assert(false);
@ -1643,6 +1649,18 @@ unittest
assertThrown!VariantException(Variant(A(3)) < Variant(A(4))); assertThrown!VariantException(Variant(A(3)) < Variant(A(4)));
} }
// Handling of void function pointers / delegates, e.g. issue 11360
unittest
{
static void t1() { }
Variant v = &t1;
assert(v() == Variant.init);
static int t2() { return 3; }
Variant v2 = &t2;
assert(v2() == 3);
}
/** /**
* Applies a delegate or function to the given Algebraic depending on the held type, * Applies a delegate or function to the given Algebraic depending on the held type,
* ensuring that all types are handled by the visiting functions. * ensuring that all types are handled by the visiting functions.