Assert (binder.Operation, ExpressionType.Add, "Operation");
AssertArgument (binder, new[] {
CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
- CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.LiteralConstant, null) // CSC bug?
+ CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null)
}, "ArgumentInfo");
Assert (arg, Enum.A, "arg");
AssertArgument (binder, new[] {
CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null),
- CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.NamedArgument | CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.LiteralConstant, "name") // CSC bug?
+ CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.NamedArgument | CSharpArgumentInfoFlags.UseCompileTimeType, "name")
}, "ArgumentInfo");
Assert ((IList<object>) args, new object[] { typeof (bool), -1 }, "args");
d (typeof (bool), name:-1);
}
-
+
void InvokeMember_1 (dynamic d, DynamicObjectMock mock)
{
mock.InvokeMemberOperation = (binder, args) => {
CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.None, null),
CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null),
CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null),
- CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.LiteralConstant | CSharpArgumentInfoFlags.UseCompileTimeType, null)
+ CSharpArgumentInfo.Create (CSharpArgumentInfoFlags.UseCompileTimeType, null)
}, "ArgumentInfo");
Assert ((IList<object>) args, new object[] { 2, 3 }, "args");
// Dynamic member lookup tests
delegate void D ();
+delegate void D2 (decimal d);
class Class
{
public const decimal Decimal = -0.3m;
+ public Class ()
+ {
+ }
+
+ public Class (sbyte extra)
+ {
+ IntValue = extra;
+ }
+
uint s = 77;
protected internal uint this[byte i] {
get {
return value;
}
+ public void MethodInOut (ref int refValue, out string outValue)
+ {
+ refValue = 3;
+ outValue = "4";
+ }
+
public static void GenericVoid<T> (T i)
{
}
class Tester
{
- delegate void EmptyDelegate ();
- delegate int IntDelegate ();
-
static void Assert<T> (T expected, T value, string name)
{
if (!EqualityComparer<T>.Default.Equals (expected, value)) {
Action<bool> f2 = Class.GenericVoid;
d = f2;
- Assert<object> (null, d (true), "#2");
+ d (true);
}
void InvokeMember ()
{
-// dynamic d = new Class ();
-// Assert ("vv", d.Method ("vv"), "#1");
+ dynamic d = new Class ();
+ Assert ("vv", d.Method ("vv"), "#1");
+
+ var arg1 = 1;
+ var arg2 = "a";
+ d.MethodInOut (ref arg1, out arg2);
- dynamic d = 2;
+ d = 2;
Assert (2, Class.StaticMethod (d), "#2");
}
+ void InvokeConstructor ()
+ {
+ dynamic d = (sbyte) 8;
+ var r = new Class (d);
+ Assert (8, r.IntValue, "#1");
+
+ D2 method = (decimal e) => { };
+ d = method;
+ var r2 = new D2 (d);
+ }
+
void MemberGetTest ()
{
dynamic d = new Class ();