示例#1
0
    public static int test_0_constrained_void_iface_call_gsharedvt_arg()
    {
        // This tests constrained calls through interfaces with one gsharedvt arg, like IComparable<T>.CompareTo ()
        IFaceConstrained c = new ClassConstrained();

        var s = new ConsStruct <int> ();

        constrained_res = null;
        c.constrained_void_iface_call_gsharedvt_arg <int, ConsStruct <int>, int> (42, s, 55);
        if (!(constrained_res is int) || ((int)constrained_res) != 42)
        {
            return(1);
        }

        var s2 = new ConsStruct <string> ();

        constrained_res = null;
        c.constrained_void_iface_call_gsharedvt_arg <string, ConsStruct <string>, int> ("A", s2, 55);
        if (!(constrained_res is string) || ((string)constrained_res) != "A")
        {
            return(2);
        }

        return(0);
    }
示例#2
0
    public static int test_0_constrained_iface_call_gsharedvt_ret()
    {
        IFaceConstrained c = new ClassConstrained();

        var s    = new ConsStruct <int> ();
        int ires = c.constrained_iface_call_gsharedvt_ret <int, ConsStruct <int>, int> (42, s, 55);

        if (ires != 42)
        {
            return(1);
        }

        var    s2   = new ConsStruct <string> ();
        string sres = c.constrained_iface_call_gsharedvt_ret <string, ConsStruct <string>, int> ("A", s2, 55);

        if (sres != "A")
        {
            return(2);
        }

        return(0);
    }
示例#3
0
    public static int test_0_constrained_void_iface_call()
    {
        IFaceConstrained c = new ClassConstrained();
        var s = new ConsStruct()
        {
            i = 42
        };

        constrained_res = null;
        c.constrained_void_iface_call <int, ConsStruct> (1, s);
        if (!(constrained_res is int) || ((int)constrained_res) != 42)
        {
            return(1);
        }
        constrained_res = null;
        c.constrained_void_iface_call_ref_arg <int, ConsStruct> (1, s);
        if (!(constrained_res is int) || ((int)constrained_res) != 42)
        {
            return(2);
        }
        var s2 = new ConsClass()
        {
            i = 43
        };

        constrained_res = null;
        c.constrained_void_iface_call <int, ConsClass> (1, s2);
        if (!(constrained_res is int) || ((int)constrained_res) != 43)
        {
            return(3);
        }
        constrained_res = null;
        c.constrained_void_iface_call_ref_arg <int, ConsClass> (1, s2);
        if (!(constrained_res is int) || ((int)constrained_res) != 43)
        {
            return(4);
        }
        return(0);
    }