annotate dmd/UnitTestDeclaration.d @ 187:b0d41ff5e0df

Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
author Abscissa
date Tue, 07 Jun 2011 23:37:34 -0400
parents cd48cb899aee
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.UnitTestDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 98
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.AggregateDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.LINK;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.TypeFunction;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Module;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.STC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.Lexer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
20 import dmd.DDMDExtensions;
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
21
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 /*******************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 * Generate unique unittest function Id so we can have multiple
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 * instances per module.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 Identifier unitTestId()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 return Lexer.uniqueId("__unittest");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 class UnitTestDeclaration : FuncDeclaration
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 {
187
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
33 mixin insertMemberExtension!(typeof(this));
b0d41ff5e0df Added expandability scheme outlined in http://www.dsource.org/forums/viewtopic.php?t=5659&sid=6f2150ff5b0bffcd47512a6a7608d218
Abscissa
parents: 179
diff changeset
34
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 this(Loc loc, Loc endloc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
178
e3afd1303184 Many small bugs fixed
korDen
parents: 114
diff changeset
37 register();
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 super(loc, endloc, unitTestId(), STC.STCundefined, null);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
41 override Dsymbol syntaxCopy(Dsymbol s)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 UnitTestDeclaration utd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 assert(!s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 utd = new UnitTestDeclaration(loc, endloc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 return FuncDeclaration.syntaxCopy(utd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
51 override void semantic(Scope sc)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 if (global.params.useUnitTests)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54 {
179
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
55 if (!type)
cd48cb899aee Updated to dmd2.040
korDen
parents: 178
diff changeset
56 type = new TypeFunction(null, Type.tvoid, false, LINKd);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 Scope sc2 = sc.push();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 sc2.linkage = LINK.LINKd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 FuncDeclaration.semantic(sc2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 sc2.pop();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62
98
5c859d5fbe27 and more
Trass3r
parents: 72
diff changeset
63 static if (false)
5c859d5fbe27 and more
Trass3r
parents: 72
diff changeset
64 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 // We're going to need ModuleInfo even if the unit tests are not
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 // compiled in, because other modules may import this module and refer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 // to this ModuleInfo.
98
5c859d5fbe27 and more
Trass3r
parents: 72
diff changeset
68 // (This doesn't make sense to me?)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 Module m = getModule();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 if (!m)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 m = sc.module_;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 if (m)
98
5c859d5fbe27 and more
Trass3r
parents: 72
diff changeset
73 {
5c859d5fbe27 and more
Trass3r
parents: 72
diff changeset
74 // writef("module3 %s needs moduleinfo\n", m.toChars());
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 m.needmoduleinfo = 1;
98
5c859d5fbe27 and more
Trass3r
parents: 72
diff changeset
76 }
5c859d5fbe27 and more
Trass3r
parents: 72
diff changeset
77 }
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
80 override AggregateDeclaration isThis()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
82 return null;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
85 override bool isVirtual()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 {
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
87 return false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
90 override bool addPreInvariant()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 {
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
92 return false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
95 override bool addPostInvariant()
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 {
12
832f71e6f96c *Exp and *AssignExp arrayOp implementation added (might be a bit incomplete)
korDen
parents: 0
diff changeset
97 return false;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
100 override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104
72
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
105 override UnitTestDeclaration isUnitTestDeclaration() { return this; }
2e2a5c3f943a reduced warnings by adding override to the methods
Trass3r
parents: 12
diff changeset
106 }