* tests/regression/resolving/TestController.java: Better error messages and
[cacao.git] / tests / regression / resolving / test_return_subtype_ok.java
1 public class test_return_subtype_ok {
2
3     public static void main(String[] args) {
4         TestController ct = new TestController();
5
6         TestLoader ld1 = new TestLoader(ClassLoader.getSystemClassLoader(), "ld1", ct);
7         TestLoader ld2 = new TestLoader(ClassLoader.getSystemClassLoader(), "ld2", ct);
8
9         ld1.addClassfile("Foo", "classes1/Foo.class");
10         ld1.addClassfile("DerivedFoo", "classes2/DerivedFoo.class");
11         ld1.addParentDelegation("java.lang.Object");
12         ld1.addParentDelegation("java.lang.String");
13
14         ld2.addClassfile("BarPassFoo", "classes2/BarPassFoo.class");
15         ld2.addDelegation("Foo", ld1);
16         ld2.addDelegation("DerivedFoo", ld1);
17         ld2.addParentDelegation("java.lang.Object");
18         ld2.addParentDelegation("java.lang.String");
19
20         // loading & linking BarPassFoo
21         ct.expect("requested", ld2, "BarPassFoo");
22         ct.expectLoadFromSystem(ld2, "java.lang.Object");
23         ct.expect("defined", ld2, "<BarPassFoo>");
24         ct.expect("loaded", ld2, "<BarPassFoo>");
25
26         Class cls = ct.loadClass(ld2, "BarPassFoo");
27
28         // executing createDerivedFoo
29         ct.expectDelegation(ld2, ld1, "DerivedFoo");
30         // ...linking (ld2, DerivedFoo)
31         ct.expect("requested", ld1, "Foo");
32         ct.expectLoadFromSystem(ld1, "java.lang.Object");
33         ct.expect("defined", ld1, "<Foo>");
34         ct.expectDelegationDefinition(ld2, ld1, "DerivedFoo");
35
36         ct.checkStringGetter(cls, "getDerivedFoo", "no exception");
37         ct.expectEnd();
38
39         // subtype check (DerivedFoo subtypeof Foo)
40         ct.expectDelegationAndFound(ld2, ld1, "Foo");
41
42         ct.checkStringGetter(cls, "getDerivedFooAsFoo", "no exception");
43
44         ct.exit();
45     }
46
47 }
48
49 // vim: et sw=4