Beispiel #1
0
    public static int test_0_super_cast()
    {
        Duper  d   = new Duper();
        Super  sup = d;
        Object o   = d;

        if (!(o is Super))
        {
            return(1);
        }
        try {
            d = (Duper)sup;
        } catch {
            return(2);
        }
        if (!(d is Object))
        {
            return(3);
        }
        try {
            d = (Duper)(object)sup;
        } catch {
            return(4);
        }
        return(0);
    }
Beispiel #2
0
    public static int test_0_super_cast_array()
    {
        Duper[]  d   = new Duper [0];
        Super[]  sup = d;
        Object[] o   = d;

        if (!(o is Super[]))
        {
            return(1);
        }
        try {
            d = (Duper[])sup;
        } catch {
            return(2);
        }
        if (!(d is Object[]))
        {
            return(3);
        }
        try {
            d = (Duper[])(object[])sup;
        } catch {
            return(4);
        }
        return(0);
    }
    public static int test_0_cast_iface_array()
    {
        object o  = new ICloneable [0];
        object o2 = new Duper [0];
        object t;
        bool   ok;

        if (!(o is object[]))
        {
            return(1);
        }
        if (!(o2 is ICloneable[]))
        {
            return(2);
        }

        try {
            ok = true;
            t  = (object[])o;
        } catch {
            ok = false;
        }
        if (!ok)
        {
            return(3);
        }

        try {
            ok = true;
            t  = (ICloneable[])o2;
        } catch {
            ok = false;
        }
        if (!ok)
        {
            return(4);
        }

        try {
            ok = true;
            t  = (ICloneable[])o;
        } catch {
            ok = false;
        }
        if (!ok)
        {
            return(5);
        }

        if (!(o is ICloneable[]))
        {
            return(6);
        }

        /* add tests for interfaces that 'inherit' interfaces */
        return(0);
    }
    public static int test_0_multi_array_cast()
    {
        Duper[,] d  = new Duper [1, 1];
        object[,] o = d;

        try {
            o [0, 0] = new Super();
            return(1);
        }
        catch (ArrayTypeMismatchException) {
        }

        return(0);
    }
Beispiel #5
0
	public static int test_0_cast_iface_array () {
		object o = new ICloneable [0];
		object o2 = new Duper [0];
		object t;
		bool ok;

		if (!(o is object[]))
			return 1;
		if (!(o2 is ICloneable[]))
			return 2;

		try {
			ok = true;
			t = (object[])o;
		} catch {
			ok = false;
		}
		if (!ok)
			return 3;
	
		try {
			ok = true;
			t = (ICloneable[])o2;
		} catch {
			ok = false;
		}
		if (!ok)
			return 4;

		try {
			ok = true;
			t = (ICloneable[])o;
		} catch {
			ok = false;
		}
		if (!ok)
			return 5;

		if (!(o is ICloneable[]))
			return 6;

		/* add tests for interfaces that 'inherit' interfaces */
		return 0;
	}
Beispiel #6
0
	public static int test_0_multi_array_cast () {
		Duper[,] d = new Duper [1, 1];
		object[,] o = d;

		try {
			o [0, 0] = new Super ();
			return 1;
		}
		catch (ArrayTypeMismatchException) {
		}

		return 0;
	}
Beispiel #7
0
	public static int test_0_super_cast_array () {
		Duper[] d = new Duper [0];
		Super[] sup = d;
		Object[] o = d;

		if (!(o is Super[]))
			return 1;
		try {
			d = (Duper[])sup;
		} catch {
			return 2;
		}
		if (!(d is Object[]))
			return 3;
		try {
			d = (Duper[])(object[])sup;
		} catch {
			return 4;
		}
		return 0;
	}
Beispiel #8
0
	public static int test_0_super_cast () {
		Duper d = new Duper ();
		Super sup = d;
		Object o = d;

		if (!(o is Super))
			return 1;
		try {
			d = (Duper)sup;
		} catch {
			return 2;
		}
		if (!(d is Object))
			return 3;
		try {
			d = (Duper)(object)sup;
		} catch {
			return 4;
		}
		return 0;
	}