Mercurial > projects > ldc
comparison tests/mini/virtcall2.d @ 1264:7ffac0079d08
Add (currently failing) test for correct virtual call resolution.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 26 Apr 2009 10:29:39 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1263:4fc43e173a0f | 1264:7ffac0079d08 |
---|---|
1 enum { | |
2 COMMON, | |
3 INPUT, | |
4 OUTPUT, | |
5 CONDUIT, | |
6 OTHER | |
7 } | |
8 | |
9 interface Common | |
10 { int common(); } | |
11 | |
12 interface Input : Common | |
13 { int input(); } | |
14 | |
15 interface Output : Common | |
16 { int output(); } | |
17 | |
18 interface Conduit : Input, Output | |
19 { abstract int conduit(); } | |
20 | |
21 class Abstract : Conduit | |
22 { | |
23 abstract int conduit(); | |
24 abstract int output(); | |
25 abstract int input(); | |
26 int common() { return COMMON; } | |
27 } | |
28 | |
29 interface Other | |
30 { int other(); } | |
31 | |
32 class Impl : Abstract, Other | |
33 { | |
34 int conduit() { return CONDUIT; } | |
35 int output() { return OUTPUT; } | |
36 int other() { return OTHER; } | |
37 int input() { return INPUT; } | |
38 } | |
39 | |
40 void main() | |
41 { | |
42 auto impl = new Impl; | |
43 | |
44 { | |
45 auto i = impl; | |
46 assert(i.common() == COMMON); | |
47 assert(i.input() == INPUT); | |
48 assert(i.output() == OUTPUT); | |
49 assert(i.conduit() == CONDUIT); | |
50 assert(i.other() == OTHER); | |
51 } | |
52 | |
53 { | |
54 Abstract i = impl; | |
55 assert(i.common() == COMMON); | |
56 assert(i.input() == INPUT); | |
57 assert(i.output() == OUTPUT); | |
58 assert(i.conduit() == CONDUIT); | |
59 } | |
60 | |
61 { | |
62 Conduit i = impl; | |
63 assert(i.common() == COMMON); | |
64 assert(i.input() == INPUT); | |
65 assert(i.output() == OUTPUT); | |
66 assert(i.conduit() == CONDUIT); | |
67 } | |
68 | |
69 { | |
70 Output i = impl; | |
71 assert(i.output() == OUTPUT); | |
72 } | |
73 | |
74 { | |
75 Common i = impl; | |
76 assert(i.common() == COMMON); | |
77 } | |
78 } |