Mercurial > projects > ddmd
annotate dmd/UnitTestDeclaration.d @ 132:c494af1dba80
Fixes for dmd 2.037
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Fri, 10 Sep 2010 19:14:09 +0100 |
parents | e28b18c23469 |
children | e3afd1303184 |
rev | line source |
---|---|
0 | 1 module dmd.UnitTestDeclaration; |
2 | |
114 | 3 import dmd.common; |
0 | 4 import dmd.FuncDeclaration; |
5 import dmd.Loc; | |
6 import dmd.Dsymbol; | |
7 import dmd.AggregateDeclaration; | |
8 import dmd.OutBuffer; | |
9 import dmd.HdrGenState; | |
10 import dmd.Type; | |
11 import dmd.Scope; | |
12 import dmd.Global; | |
13 import dmd.LINK; | |
14 import dmd.TypeFunction; | |
15 import dmd.Module; | |
16 import dmd.STC; | |
17 import dmd.Lexer; | |
18 import dmd.Identifier; | |
19 | |
20 /******************************* | |
21 * Generate unique unittest function Id so we can have multiple | |
22 * instances per module. | |
23 */ | |
24 Identifier unitTestId() | |
25 { | |
26 return Lexer.uniqueId("__unittest"); | |
27 } | |
28 | |
29 class UnitTestDeclaration : FuncDeclaration | |
30 { | |
31 this(Loc loc, Loc endloc) | |
32 { | |
33 super(loc, endloc, unitTestId(), STC.STCundefined, null); | |
34 } | |
35 | |
72 | 36 override Dsymbol syntaxCopy(Dsymbol s) |
0 | 37 { |
38 UnitTestDeclaration utd; | |
39 | |
40 assert(!s); | |
41 utd = new UnitTestDeclaration(loc, endloc); | |
42 | |
43 return FuncDeclaration.syntaxCopy(utd); | |
44 } | |
45 | |
72 | 46 override void semantic(Scope sc) |
0 | 47 { |
48 if (global.params.useUnitTests) | |
49 { | |
50 type = new TypeFunction(null, Type.tvoid, false, LINKd); | |
51 Scope sc2 = sc.push(); | |
52 sc2.linkage = LINK.LINKd; | |
53 FuncDeclaration.semantic(sc2); | |
54 sc2.pop(); | |
55 } | |
56 | |
98 | 57 static if (false) |
58 { | |
0 | 59 // We're going to need ModuleInfo even if the unit tests are not |
60 // compiled in, because other modules may import this module and refer | |
61 // to this ModuleInfo. | |
98 | 62 // (This doesn't make sense to me?) |
0 | 63 Module m = getModule(); |
64 if (!m) | |
65 m = sc.module_; | |
66 if (m) | |
98 | 67 { |
68 // writef("module3 %s needs moduleinfo\n", m.toChars()); | |
0 | 69 m.needmoduleinfo = 1; |
98 | 70 } |
71 } | |
0 | 72 } |
73 | |
72 | 74 override AggregateDeclaration isThis() |
0 | 75 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
76 return null; |
0 | 77 } |
78 | |
72 | 79 override bool isVirtual() |
0 | 80 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
81 return false; |
0 | 82 } |
83 | |
72 | 84 override bool addPreInvariant() |
0 | 85 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
86 return false; |
0 | 87 } |
88 | |
72 | 89 override bool addPostInvariant() |
0 | 90 { |
12
832f71e6f96c
*Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents:
0
diff
changeset
|
91 return false; |
0 | 92 } |
93 | |
72 | 94 override void toCBuffer(OutBuffer buf, HdrGenState* hgs) |
0 | 95 { |
96 assert(false); | |
97 } | |
98 | |
72 | 99 override UnitTestDeclaration isUnitTestDeclaration() { return this; } |
100 } |