@@ -35,11 +35,11 @@ SCENARIO("journalling_symbol_table_writer",
35
35
const symbol_tablet &read_symbol_table=symbol_table;
36
36
37
37
irep_idt symbol_name=" Test" ;
38
- symbolt symbol;
39
- symbol.name =symbol_name;
40
38
41
39
WHEN (" A symbol is inserted into the symbol table" )
42
40
{
41
+ symbolt symbol;
42
+ symbol.name =symbol_name;
43
43
auto result=symbol_table.insert (symbol);
44
44
THEN (" The insert should succeed" )
45
45
{
@@ -68,8 +68,6 @@ SCENARIO("journalling_symbol_table_writer",
68
68
}
69
69
WHEN (" Adding the same symbol again" )
70
70
{
71
- symbolt symbol;
72
- symbol.name =symbol_name;
73
71
auto result=symbol_table.insert (symbol);
74
72
THEN (" The insert should fail" )
75
73
{
@@ -79,6 +77,8 @@ SCENARIO("journalling_symbol_table_writer",
79
77
}
80
78
WHEN (" Moving a symbol into the symbol table" )
81
79
{
80
+ symbolt symbol;
81
+ symbol.name =symbol_name;
82
82
symbolt *symbol_in_table;
83
83
auto result=symbol_table.move (symbol, symbol_in_table);
84
84
THEN (" The move should succeed" )
@@ -104,8 +104,6 @@ SCENARIO("journalling_symbol_table_writer",
104
104
}
105
105
WHEN (" Moving the same symbol again" )
106
106
{
107
- symbolt symbol;
108
- symbol.name =symbol_name;
109
107
symbolt *symbol_in_table2;
110
108
auto result=symbol_table.move (symbol, symbol_in_table2);
111
109
THEN (" The move should fail" )
@@ -120,6 +118,8 @@ SCENARIO("journalling_symbol_table_writer",
120
118
}
121
119
WHEN (" Adding a symbol to the symbol table" )
122
120
{
121
+ symbolt symbol;
122
+ symbol.name =symbol_name;
123
123
auto result=symbol_table.add (symbol);
124
124
THEN (" The add should succeed" )
125
125
{
@@ -144,8 +144,6 @@ SCENARIO("journalling_symbol_table_writer",
144
144
}
145
145
WHEN (" Adding the same symbol again" )
146
146
{
147
- symbolt symbol;
148
- symbol.name =symbol_name;
149
147
auto result=symbol_table.add (symbol);
150
148
THEN (" The insert should fail" )
151
149
{
@@ -155,6 +153,8 @@ SCENARIO("journalling_symbol_table_writer",
155
153
}
156
154
WHEN (" Updating an existing symbol" )
157
155
{
156
+ symbolt symbol;
157
+ symbol.name =symbol_name;
158
158
base_symbol_table.add (symbol);
159
159
symbolt *writeable=symbol_table.get_writeable (symbol_name);
160
160
@@ -183,20 +183,22 @@ SCENARIO("journalling_symbol_table_writer",
183
183
}
184
184
WHEN (" Removing a non-existent symbol" )
185
185
{
186
- irep_idt symbol_name =" DoesNotExist" ;
187
- bool ret=symbol_table.remove (symbol_name );
186
+ irep_idt no_such_symbol_name =" DoesNotExist" ;
187
+ bool ret=symbol_table.remove (no_such_symbol_name );
188
188
THEN (" The remove operation should fail" )
189
189
{
190
190
REQUIRE (ret);
191
191
}
192
192
THEN (" The symbol we failed to remove should appear in neither journal" )
193
193
{
194
- REQUIRE (symbol_table.get_updated ().count (symbol_name)== 0 );
195
- REQUIRE (symbol_table.get_removed ().count (symbol_name)== 0 );
194
+ REQUIRE (symbol_table.get_updated ().count (no_such_symbol_name) == 0 );
195
+ REQUIRE (symbol_table.get_removed ().count (no_such_symbol_name) == 0 );
196
196
}
197
197
}
198
198
WHEN (" Removing an existing symbol added via the journalling writer" )
199
199
{
200
+ symbolt symbol;
201
+ symbol.name =symbol_name;
200
202
symbol_table.add (symbol);
201
203
bool ret=symbol_table.remove (symbol_name);
202
204
THEN (" The remove operation should succeed" )
@@ -211,6 +213,8 @@ SCENARIO("journalling_symbol_table_writer",
211
213
}
212
214
WHEN (" Removing an existing symbol added outside the journalling writer" )
213
215
{
216
+ symbolt symbol;
217
+ symbol.name =symbol_name;
214
218
base_symbol_table.add (symbol);
215
219
bool ret=symbol_table.remove (symbol_name);
216
220
THEN (" The remove operation should succeed" )
@@ -226,6 +230,8 @@ SCENARIO("journalling_symbol_table_writer",
226
230
}
227
231
WHEN (" Removing an existing symbol using an iterator (added via writer)" )
228
232
{
233
+ symbolt symbol;
234
+ symbol.name =symbol_name;
229
235
symbol_table.add (symbol);
230
236
auto erase_iterator=read_symbol_table.symbols .find (symbol_name);
231
237
symbol_table.erase (erase_iterator);
@@ -237,6 +243,8 @@ SCENARIO("journalling_symbol_table_writer",
237
243
}
238
244
WHEN (" Removing an existing symbol using an iterator (added via base)" )
239
245
{
246
+ symbolt symbol;
247
+ symbol.name =symbol_name;
240
248
base_symbol_table.add (symbol);
241
249
auto erase_iterator=read_symbol_table.symbols .find (symbol_name);
242
250
symbol_table.erase (erase_iterator);
@@ -248,6 +256,8 @@ SCENARIO("journalling_symbol_table_writer",
248
256
}
249
257
WHEN (" Re-adding a symbol previously removed" )
250
258
{
259
+ symbolt symbol;
260
+ symbol.name =symbol_name;
251
261
auto result=symbol_table.add (symbol);
252
262
symbol_table.remove (symbol.name );
253
263
auto result2=symbol_table.add (symbol);
0 commit comments