/
assignable-tests.cs
69 lines (63 loc) · 1.42 KB
/
assignable-tests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
namespace Test {
public interface A {
void method ();
}
public interface B : A {
void method2 ();
}
public class test {
public static int Main () {
Type int_type = typeof (int);
Type obj_type = typeof (object);
Type vt_type = typeof (System.ValueType);
Type comp_type = typeof (System.IComparable);
Type a_type = typeof (A);
Type b_type = typeof (B);
int error = 1;
if (!int_type.IsSubclassOf(vt_type))
return error;
++error;
if (!int_type.IsSubclassOf(obj_type))
return error;
++error;
if (int_type.IsSubclassOf(comp_type))
return error;
++error;
if (int_type.IsAssignableFrom(vt_type))
return error;
++error;
if (int_type.IsAssignableFrom (obj_type))
return error;
++error;
if (int_type.IsAssignableFrom(comp_type))
return error;
++error;
if (!int_type.IsAssignableFrom(int_type))
return error;
++error;
if (!obj_type.IsAssignableFrom (int_type))
return error;
++error;
if (!vt_type.IsAssignableFrom(int_type))
return error;
++error;
if (!comp_type.IsAssignableFrom(int_type))
return error;
++error;
if (a_type.IsSubclassOf(b_type))
return error;
++error;
if (b_type.IsAssignableFrom(a_type))
return error;
++error;
if (b_type.IsSubclassOf(a_type))
return error;
++error;
if (!a_type.IsAssignableFrom(b_type))
return error;
++error;
return 0;
}
}
}