Mercurial > projects > ldc
annotate tests/mini/dgs.d @ 1607:207a8a438dea
Merge DMD r253: refactor: Argument => Parameter
---
dmd/arrayop.c | 30 ++++----
dmd/arraytypes.h | 2 +-
dmd/class.c | 8 +-
dmd/declaration.c | 10 ++--
dmd/declaration.h | 16 ++--
dmd/doc.c | 12 ++--
dmd/dsymbol.c | 4 +-
dmd/expression.c | 48 +++++++-------
dmd/expression.h | 32 +++++-----
dmd/func.c | 78 +++++++++++-----------
dmd/init.c | 2 +-
dmd/interpret.c | 8 +-
dmd/mtype.c | 190 ++++++++++++++++++++++++++--------------------------
dmd/mtype.h | 32 +++++-----
dmd/opover.c | 34 +++++-----
dmd/parse.c | 40 ++++++------
dmd/parse.h | 2 +-
dmd/statement.c | 90 +++++++++++++-------------
dmd/statement.h | 14 ++--
dmd/struct.c | 8 +-
dmd/template.c | 30 ++++----
gen/functions.cpp | 10 ++--
gen/functions.h | 2 +-
gen/tocall.cpp | 10 ++--
gen/typinf.cpp | 6 +-
25 files changed, 359 insertions(+), 359 deletions(-)
author | Leandro Lucarella <llucax@gmail.com> |
---|---|
date | Wed, 06 Jan 2010 15:18:20 -0300 |
parents | 1bb99290e03a |
children |
rev | line source |
---|---|
270
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
1
diff
changeset
|
1 |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
1
diff
changeset
|
2 extern(C) int printf(char*, ...); |
d9d5d59873d8
[svn r291] Fixed a bunch of the old Phobos tests to work with Tango.
lindquist
parents:
1
diff
changeset
|
3 |
1 | 4 struct S |
5 { | |
6 int i; | |
7 int square() | |
8 { | |
9 return i*i; | |
10 } | |
11 int plus(int a) | |
12 { | |
13 return i + a; | |
14 } | |
15 int minus(int a) | |
16 { | |
17 return i - a; | |
18 } | |
19 int delegate(int) get(char op) | |
20 { | |
21 int delegate(int) rval; | |
22 if (op == '+') | |
23 rval = + | |
24 else if (op == '-') | |
25 rval = − | |
26 return rval; | |
27 } | |
28 } | |
29 | |
30 int calldg1(int delegate(int) dg, int i) | |
31 { | |
32 return dg(i); | |
33 } | |
34 | |
35 void delegate() retdg() | |
36 { | |
37 void delegate() dg; | |
38 return dg; | |
39 } | |
40 | |
41 void getretdg() | |
42 { | |
43 void delegate() dg; | |
44 dg = retdg(); | |
45 } | |
46 | |
47 class C | |
48 { | |
49 int i; | |
50 void m() | |
51 { | |
52 i = 42; | |
53 } | |
54 } | |
55 | |
56 void getclassdg() | |
57 { | |
58 scope c = new C; | |
59 void delegate() dg = &c.m; | |
60 assert(c.i != 42); | |
61 dg(); | |
62 assert(c.i == 42); | |
63 } | |
64 | |
65 void main() | |
66 { | |
67 printf("Delegate test\n"); | |
68 S s = S(4); | |
69 | |
70 auto dg = &s.square; | |
71 //assert(dg() == 16); | |
72 //dg(); | |
73 | |
74 /*auto dg1 = &s.plus; | |
75 assert(dg1(6) == 10); | |
76 | |
77 auto dg2 = &s.minus; | |
78 assert(calldg1(dg2,30) == -26); | |
79 | |
80 auto dg3 = s.get('+'); | |
81 assert(dg3(16) == 20); | |
82 | |
83 getretdg(); | |
84 getclassdg();*/ | |
85 | |
86 printf(" SUCCESS\n"); | |
87 } |