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