@@ -29,7 +29,6 @@ struct test_datat
29
29
// / \param test_data The data to run the test on
30
30
void require_is_constructor (const test_datat &test_data)
31
31
{
32
-
33
32
const symbolt &constructor =
34
33
test_data.symbol_table .lookup_ref (test_data.constructor_descriptor );
35
34
THEN (" The constructor should be marked as a constructor" )
@@ -66,22 +65,18 @@ SCENARIO(
66
65
std::string base_constructor_name = " java::ClassWithConstructors.<init>" ;
67
66
WHEN (" Looking at the parameterless constructor" )
68
67
{
69
- require_is_constructor ([&]() {
70
- test_datat data;
71
- data.constructor_descriptor = base_constructor_name + " :()V" ;
72
- data.symbol_table = symbol_table;
73
- return data;
74
- }());
68
+ test_datat data;
69
+ data.constructor_descriptor = base_constructor_name + " :()V" ;
70
+ data.symbol_table = symbol_table;
71
+ require_is_constructor (data);
75
72
}
76
73
WHEN (" Looking at the parametered constructor" )
77
74
{
78
- require_is_constructor ([&]() {
79
- test_datat data;
80
- data.constructor_descriptor =
81
- base_constructor_name + " :(ILjava/lang/Object;LOpaqueClass;)V" ;
82
- data.symbol_table = symbol_table;
83
- return data;
84
- }());
75
+ test_datat data;
76
+ data.constructor_descriptor =
77
+ base_constructor_name + " :(ILjava/lang/Object;LOpaqueClass;)V" ;
78
+ data.symbol_table = symbol_table;
79
+ require_is_constructor (data);
85
80
}
86
81
}
87
82
GIVEN (" A class without any constructors" )
@@ -92,12 +87,10 @@ SCENARIO(
92
87
std::string base_constructor_name = " java::ClassWithoutConstructors.<init>" ;
93
88
WHEN (" Looking at the default constructor" )
94
89
{
95
- require_is_constructor ([&]() {
96
- test_datat data;
97
- data.constructor_descriptor = base_constructor_name + " :()V" ;
98
- data.symbol_table = symbol_table;
99
- return data;
100
- }());
90
+ test_datat data;
91
+ data.constructor_descriptor = base_constructor_name + " :()V" ;
92
+ data.symbol_table = symbol_table;
93
+ require_is_constructor (data);
101
94
}
102
95
}
103
96
GIVEN (" A class with both constructors and static initalisers" )
@@ -109,33 +102,27 @@ SCENARIO(
109
102
std::string base_constructor_name = base_class_name + " <init>" ;
110
103
WHEN (" Looking at the parameterless constructor" )
111
104
{
112
- require_is_constructor ([&]() {
113
- test_datat data;
114
- data.constructor_descriptor = base_constructor_name + " :()V" ;
115
- data.symbol_table = symbol_table;
116
- return data;
117
- }());
105
+ test_datat data;
106
+ data.constructor_descriptor = base_constructor_name + " :()V" ;
107
+ data.symbol_table = symbol_table;
108
+ require_is_constructor (data);
118
109
}
119
110
WHEN (" Looking at the parametered constructor" )
120
111
{
121
- require_is_constructor ([&]() {
122
- test_datat data;
123
- data.constructor_descriptor =
124
- base_constructor_name + " :(ILjava/lang/Object;LOpaqueClass;)V" ;
125
- data.symbol_table = symbol_table;
126
- return data;
127
- }());
112
+ test_datat data;
113
+ data.constructor_descriptor =
114
+ base_constructor_name + " :(ILjava/lang/Object;LOpaqueClass;)V" ;
115
+ data.symbol_table = symbol_table;
116
+ require_is_constructor (data);
128
117
}
129
118
WHEN (" Looking at the static initalizer" )
130
119
{
131
120
THEN (" The static init should not be marked as a constructor" )
132
121
{
133
- require_is_static_initalizer ([&]() {
134
- test_datat data;
135
- data.constructor_descriptor = base_class_name + " <clinit>:()V" ;
136
- data.symbol_table = symbol_table;
137
- return data;
138
- }());
122
+ test_datat data;
123
+ data.constructor_descriptor = base_class_name + " <clinit>:()V" ;
124
+ data.symbol_table = symbol_table;
125
+ require_is_static_initializer (data);
139
126
}
140
127
}
141
128
}
@@ -151,23 +138,19 @@ SCENARIO(
151
138
152
139
WHEN (" Looking at the default constructor" )
153
140
{
154
- require_is_constructor ([&]() {
155
- test_datat data;
156
- data.constructor_descriptor = base_constructor_name + " :()V" ;
157
- data.symbol_table = symbol_table;
158
- return data;
159
- }());
141
+ test_datat data;
142
+ data.constructor_descriptor = base_constructor_name + " :()V" ;
143
+ data.symbol_table = symbol_table;
144
+ require_is_constructor (data);
160
145
}
161
146
WHEN (" Looking at the static initalizer" )
162
147
{
163
148
THEN (" The static init should not be marked as a constructor" )
164
149
{
165
- require_is_static_initalizer ([&]() {
166
- test_datat data;
167
- data.constructor_descriptor = base_class_name + " <clinit>:()V" ;
168
- data.symbol_table = symbol_table;
169
- return data;
170
- }());
150
+ test_datat data;
151
+ data.constructor_descriptor = base_class_name + " <clinit>:()V" ;
152
+ data.symbol_table = symbol_table;
153
+ require_is_static_initializer (data);
171
154
}
172
155
}
173
156
}
@@ -182,23 +165,19 @@ SCENARIO(
182
165
183
166
WHEN (" Looking at the parameterless constructor" )
184
167
{
185
- require_is_constructor ([&]() {
186
- test_datat data;
187
- data.constructor_descriptor = base_constructor_name + " :()V" ;
188
- data.symbol_table = symbol_table;
189
- return data;
190
- }());
168
+ test_datat data;
169
+ data.constructor_descriptor = base_constructor_name + " :()V" ;
170
+ data.symbol_table = symbol_table;
171
+ require_is_constructor (data);
191
172
}
192
173
WHEN (" Looking at the static initalizer for the opaque class" )
193
174
{
194
175
THEN (" The static init should not be marked as a constructor" )
195
176
{
196
- require_is_static_initalizer ([&]() {
197
- test_datat data;
198
- data.constructor_descriptor = " java::OpaqueClass.<clinit>:()V" ;
199
- data.symbol_table = symbol_table;
200
- return data;
201
- }());
177
+ test_datat data;
178
+ data.constructor_descriptor = " java::OpaqueClass.<clinit>:()V" ;
179
+ data.symbol_table = symbol_table;
180
+ require_is_static_initializer (data);
202
181
}
203
182
}
204
183
}
@@ -217,35 +196,29 @@ SCENARIO(
217
196
218
197
WHEN (" Looking at the parameterless constructor" )
219
198
{
220
- require_is_constructor ([&]() {
221
- test_datat data;
222
- data.constructor_descriptor = base_constructor_name + " :()V" ;
223
- data.symbol_table = symbol_table;
224
- return data;
225
- }());
199
+ test_datat data;
200
+ data.constructor_descriptor = base_constructor_name + " :()V" ;
201
+ data.symbol_table = symbol_table;
202
+ require_is_constructor (data);
226
203
}
227
204
WHEN (" Looking at the static initalizer for the opaque class" )
228
205
{
229
206
THEN (" The static init should not be marked as a constructor" )
230
207
{
231
- require_is_static_initalizer ([&]() {
232
- test_datat data;
233
- data.constructor_descriptor = " java::OpaqueClass.<clinit>:()V" ;
234
- data.symbol_table = symbol_table;
235
- return data;
236
- }());
208
+ test_datat data;
209
+ data.constructor_descriptor = " java::OpaqueClass.<clinit>:()V" ;
210
+ data.symbol_table = symbol_table;
211
+ require_is_static_initializer (data);
237
212
}
238
213
}
239
214
WHEN (" Looking at the constructor for the opaque class" )
240
215
{
241
216
THEN (" The static init should not be marked as a constructor" )
242
217
{
243
- require_is_constructor ([&]() {
244
- test_datat data;
245
- data.constructor_descriptor = " java::OpaqueClass.<init>:()V" ;
246
- data.symbol_table = symbol_table;
247
- return data;
248
- }());
218
+ test_datat data;
219
+ data.constructor_descriptor = " java::OpaqueClass.<init>:()V" ;
220
+ data.symbol_table = symbol_table;
221
+ require_is_constructor (data);
249
222
}
250
223
}
251
224
}
0 commit comments