Mercurial > projects > ldc
diff test/interface3.d @ 113:27b9f749d9fe trunk
[svn r117] Initial working implementation of interfaces.
Groundwork for all the different types of class/interface casts laid out.
author | lindquist |
---|---|
date | Sat, 24 Nov 2007 06:33:00 +0100 |
parents | |
children | 44a95ac7368a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/interface3.d Sat Nov 24 06:33:00 2007 +0100 @@ -0,0 +1,28 @@ +module interface3; + +interface I +{ + void func(); +} + +class C : I +{ + int i = 42; + override void func() + { + printf("hello %d\n", i); + i++; + } +} + +void main() +{ + scope c = new C; + {c.func();} + { + I i = c; + {i.func();} + } + {printf("final %d\n", c.i);} + {assert(c.i == 44);} +}