示例#1
0
文件: generics.cs 项目: zer09/Cosmos
    public static int test_0_ldfld_stfld_mro()
    {
        MRO m = new MRO();
        GenericStruct <int> s = new GenericStruct <int>(5);

        // This generates stfld
        m.struct_field = s;

        // This generates ldflda
        if (m.struct_field.t != 5)
        {
            return(1);
        }

        // This generates ldfld
        GenericStruct <int> s2 = m.struct_field;

        if (s2.t != 5)
        {
            return(2);
        }

        if (m.struct_field.t != 5)
        {
            return(3);
        }

        m.class_field = new GenericClass <int>(5);
        if (m.class_field.t != 5)
        {
            return(4);
        }

        return(0);
    }
	public static int test_0_ldfld_stfld_mro () {
		MRO m = new MRO ();
		GenericStruct<int> s = new GenericStruct<int> (5);
		// This generates stfld
		m.struct_field = s;

		// This generates ldflda
		if (m.struct_field.t != 5)
			return 1;

		// This generates ldfld
		GenericStruct<int> s2 = m.struct_field;
		if (s2.t != 5)
			return 2;

		if (m.struct_field.t != 5)
			return 3;

		m.class_field = new GenericClass<int> (5);
		if (m.class_field.t != 5)
			return 4;

		// gshared
		var m2 = new MRO<string> ();
		if (m2.stfld_ldfld ("A") != "A")
			return 5;

		return 0;
	}