Mercurial > projects > dstress
comparison run/mini/nested17.d @ 1628:c6ef09dfba4d
add mini test set from ldc project
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Mon, 10 Jan 2011 19:47:18 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1627:e1b954780837 | 1628:c6ef09dfba4d |
---|---|
1 // $HeadURL: svn://svn.berlios.de/dstress/trunk/run/n/nested_class_03_A.d $ | |
2 // $Date: 2005-06-18 09:15:32 +0200 (Sat, 18 Jun 2005) $ | |
3 // $Author: thomask $ | |
4 | |
5 // @author@ John C <johnch_atms@hotmail.com> | |
6 // @date@ 2005-06-09 | |
7 // @uri@ news:d88vta$vak$1@digitaldaemon.com | |
8 | |
9 //module dstress.run.n.nested_class_03_A; | |
10 module mini.nested17; | |
11 | |
12 interface Inner{ | |
13 int value(); | |
14 } | |
15 | |
16 class Outer{ | |
17 int x; | |
18 | |
19 Inner test(){ | |
20 printf("val = %d\n", x); | |
21 return new class Inner { | |
22 int y; | |
23 | |
24 this(){ | |
25 printf("val = %d\n", x); | |
26 y=x; | |
27 } | |
28 | |
29 int value(){ | |
30 return y; | |
31 } | |
32 }; | |
33 } | |
34 } | |
35 | |
36 int main(){ | |
37 Outer o = new Outer(); | |
38 o.x=2; | |
39 int val = o.test().value(); | |
40 printf("val = %d\n", val); | |
41 assert(val == o.x); | |
42 return 0; | |
43 } | |
44 | |
45 extern(C) int printf(char*, ...); |