예제 #1
0
    [Category("!WASM")]      //Interp fails
    public static int test_0_large_nullable_invoke()
    {
        var s = new LargeStruct()
        {
            a = 1, b = 2, c = 3, d = 4
        };

        NullableMethods.GetHasValue <LargeStruct> (s);

        var m = typeof(NullableMethods).GetMethod("GetHasValue", BindingFlags.Static | BindingFlags.Public);

        Type type = typeof(LargeStruct?).GetGenericArguments() [0];
        bool b1   = (bool)m.MakeGenericMethod(new Type[] { type }).Invoke(null, new object[] { s });

        if (!b1)
        {
            return(1);
        }
        bool b2 = (bool)m.MakeGenericMethod(new Type[] { type }).Invoke(null, new object[] { null });

        if (b2)
        {
            return(2);
        }
        return(0);
    }
예제 #2
0
    public static int test_0_dyncall_nullable()
    {
        int?v;

        v = 42;
        NullableMethods.GetHasValue(v);
        bool b = (bool)typeof(NullableMethods).GetMethod("GetHasValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });

        if (!b)
        {
            return(1);
        }
        v = null;
        b = (bool)typeof(NullableMethods).GetMethod("GetHasValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });
        if (b)
        {
            return(2);
        }

        v = 42;
        NullableMethods.GetValue(v);
        var res = (int)typeof(NullableMethods).GetMethod("GetValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });

        if (res != 42)
        {
            return(3);
        }
        return(0);
    }
예제 #3
0
    public static int test_0_dyncall_nullable()
    {
        int?v;

        v = 42;
        NullableMethods.GetHasValue(v);
        bool b = (bool)typeof(NullableMethods).GetMethod("GetHasValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });

        if (!b)
        {
            return(1);
        }
        v = null;
        b = (bool)typeof(NullableMethods).GetMethod("GetHasValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });
        if (b)
        {
            return(2);
        }

        v = 42;
        NullableMethods.GetValue(v);
        var res = (int)typeof(NullableMethods).GetMethod("GetValue").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { v });

        if (res != 42)
        {
            return(3);
        }

        NullableMethods.Get(42);
        var res2 = (int?)typeof(NullableMethods).GetMethod("Get").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { 42 });

        if (res2 != 42)
        {
            return(4);
        }
        res2 = (int?)typeof(NullableMethods).GetMethod("GetNull").MakeGenericMethod(new Type [] { typeof(int) }).Invoke(null, new object [] { });
        if (res2.HasValue)
        {
            return(5);
        }

        NullableMethods.NullableMany(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8);
        res2 = (int?)typeof(NullableMethods).GetMethod("NullableMany").Invoke(null, new object [] { 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L });
        if (res2 != 36)
        {
            return(6);
        }
        return(0);
    }