Mercurial > projects > dstress
comparison run/mini/d.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 module d; | |
2 | |
3 void main() | |
4 { | |
5 int delegate() dg; | |
6 | |
7 struct S | |
8 { | |
9 int i; | |
10 long l; | |
11 float f; | |
12 | |
13 int func() | |
14 { | |
15 return 42; | |
16 } | |
17 } | |
18 | |
19 S s; | |
20 auto dg2 = &s.func; | |
21 int i = dg2(); | |
22 assert(i == 42); | |
23 | |
24 i = f(dg2, 1); | |
25 assert(i == 43); | |
26 } | |
27 | |
28 int f(int delegate() dg, int i) | |
29 { | |
30 return dg() + i; | |
31 } | |
32 | |
33 /* | |
34 struct S | |
35 { | |
36 int i; | |
37 float f; | |
38 int square() | |
39 { | |
40 return i*i; | |
41 } | |
42 } | |
43 | |
44 S s; | |
45 | |
46 void main() | |
47 { | |
48 auto dg = &s.square; | |
49 } | |
50 */ |