anbt-sql-formatter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/anbt-sql-formatter +0 -3
- data/lib/anbt-sql-formatter/coarse-tokenizer.rb +1 -3
- data/lib/anbt-sql-formatter/exception.rb +0 -2
- data/lib/anbt-sql-formatter/formatter.rb +50 -57
- data/lib/anbt-sql-formatter/helper.rb +42 -56
- data/lib/anbt-sql-formatter/parser.rb +40 -52
- data/lib/anbt-sql-formatter/rule.rb +5 -2
- data/lib/anbt-sql-formatter/token.rb +1 -10
- data/lib/anbt-sql-formatter/version.rb +1 -1
- data/test/helper.rb +7 -1
- data/test/test_coarse-tokenizer.rb +327 -228
- data/test/test_formatter.rb +363 -276
- data/test/test_helper.rb +2 -2
- data/test/test_parser.rb +302 -213
- data/test/test_rule.rb +10 -8
- metadata +21 -31
data/test/test_formatter.rb
CHANGED
@@ -16,6 +16,9 @@ class TestAnbtSqlFormatter < Test::Unit::TestCase
|
|
16
16
|
@fmt = AnbtSql::Formatter.new(@rule)
|
17
17
|
end
|
18
18
|
|
19
|
+
def _format(tokens)
|
20
|
+
Helper.format_tokens(tokens)
|
21
|
+
end
|
19
22
|
|
20
23
|
def test_modify_keyword_case
|
21
24
|
msg = "upcase"
|
@@ -25,12 +28,15 @@ class TestAnbtSqlFormatter < Test::Unit::TestCase
|
|
25
28
|
|
26
29
|
tokens = @parser.parse("select")
|
27
30
|
@fmt.modify_keyword_case(tokens)
|
28
|
-
assert_equals(
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
assert_equals(
|
32
|
+
msg + "",
|
33
|
+
strip_indent(
|
34
|
+
<<-EOB
|
35
|
+
keyword (SELECT)
|
36
|
+
EOB
|
37
|
+
),
|
38
|
+
_format(tokens)
|
39
|
+
)
|
34
40
|
|
35
41
|
########
|
36
42
|
msg = "downcase"
|
@@ -38,12 +44,15 @@ EOB
|
|
38
44
|
|
39
45
|
tokens = @parser.parse("SELECT")
|
40
46
|
@fmt.modify_keyword_case(tokens)
|
41
|
-
assert_equals(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
assert_equals(
|
48
|
+
msg + "",
|
49
|
+
strip_indent(
|
50
|
+
<<-EOB
|
51
|
+
keyword (select)
|
52
|
+
EOB
|
53
|
+
),
|
54
|
+
_format(tokens)
|
55
|
+
)
|
47
56
|
end
|
48
57
|
|
49
58
|
|
@@ -53,34 +62,42 @@ EOB
|
|
53
62
|
########
|
54
63
|
tokens = @parser.parse("a+")
|
55
64
|
@fmt.concat_operator_for_oracle(tokens)
|
56
|
-
assert_equals(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
65
|
+
assert_equals(
|
66
|
+
msg + "length is less than 3, should do nothing",
|
67
|
+
strip_indent(
|
68
|
+
<<-EOB
|
69
|
+
name (a)
|
70
|
+
symbol (+)
|
71
|
+
EOB
|
72
|
+
),
|
73
|
+
_format(tokens)
|
74
|
+
)
|
64
75
|
|
65
76
|
########
|
66
77
|
tokens = @parser.parse("(+)")
|
67
78
|
@fmt.concat_operator_for_oracle(tokens)
|
68
|
-
assert_equals(
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
79
|
+
assert_equals(
|
80
|
+
msg + "",
|
81
|
+
strip_indent(
|
82
|
+
<<-EOB
|
83
|
+
symbol ((+))
|
84
|
+
EOB
|
85
|
+
),
|
86
|
+
_format(tokens)
|
87
|
+
)
|
74
88
|
|
75
89
|
########
|
76
90
|
tokens = @parser.parse("(+)")
|
77
91
|
tokens = @fmt.format_list(tokens)
|
78
|
-
assert_equals(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
92
|
+
assert_equals(
|
93
|
+
msg + "format_list()",
|
94
|
+
strip_indent(
|
95
|
+
<<-EOB
|
96
|
+
symbol ((+))
|
97
|
+
EOB
|
98
|
+
),
|
99
|
+
_format(tokens)
|
100
|
+
)
|
84
101
|
end
|
85
102
|
|
86
103
|
|
@@ -90,40 +107,48 @@ EOB
|
|
90
107
|
########
|
91
108
|
tokens = @parser.parse("a (b")
|
92
109
|
@fmt.remove_symbol_side_space(tokens)
|
93
|
-
assert_equals(
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
110
|
+
assert_equals(
|
111
|
+
msg + "",
|
112
|
+
strip_indent(
|
113
|
+
<<-EOB
|
114
|
+
name (a)
|
115
|
+
symbol (()
|
116
|
+
name (b)
|
117
|
+
EOB
|
118
|
+
),
|
119
|
+
_format(tokens)
|
120
|
+
)
|
101
121
|
|
102
122
|
|
103
123
|
########
|
104
124
|
tokens = @parser.parse("a( b")
|
105
125
|
@fmt.remove_symbol_side_space(tokens)
|
106
|
-
assert_equals(
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
126
|
+
assert_equals(
|
127
|
+
msg + "", strip_indent(
|
128
|
+
<<-EOB
|
129
|
+
name (a)
|
130
|
+
symbol (()
|
131
|
+
name (b)
|
132
|
+
EOB
|
133
|
+
),
|
134
|
+
_format(tokens)
|
135
|
+
)
|
114
136
|
|
115
137
|
|
116
138
|
########
|
117
139
|
tokens = @parser.parse("a ( b")
|
118
140
|
@fmt.remove_symbol_side_space(tokens)
|
119
|
-
assert_equals(
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
141
|
+
assert_equals(
|
142
|
+
msg + "",
|
143
|
+
strip_indent(
|
144
|
+
<<-EOB
|
145
|
+
name (a)
|
146
|
+
symbol (()
|
147
|
+
name (b)
|
148
|
+
EOB
|
149
|
+
),
|
150
|
+
_format(tokens)
|
151
|
+
)
|
127
152
|
end
|
128
153
|
|
129
154
|
|
@@ -133,27 +158,33 @@ EOB
|
|
133
158
|
########
|
134
159
|
tokens = @parser.parse("( 1 )")
|
135
160
|
@fmt.special_treatment_for_parenthesis_with_one_element(tokens)
|
136
|
-
assert_equals(
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
161
|
+
assert_equals(
|
162
|
+
msg + "one element, should not separate",
|
163
|
+
strip_indent(
|
164
|
+
<<-EOB
|
165
|
+
symbol ((1))
|
166
|
+
EOB
|
167
|
+
),
|
168
|
+
_format(tokens)
|
169
|
+
)
|
142
170
|
|
143
171
|
|
144
172
|
########
|
145
173
|
tokens = @parser.parse("(1,2)")
|
146
174
|
@fmt.special_treatment_for_parenthesis_with_one_element(tokens)
|
147
|
-
assert_equals(
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
175
|
+
assert_equals(
|
176
|
+
msg + "more than one element, should separate",
|
177
|
+
strip_indent(
|
178
|
+
<<-EOB
|
179
|
+
symbol (()
|
180
|
+
value (1)
|
181
|
+
symbol (,)
|
182
|
+
value (2)
|
183
|
+
symbol ())
|
184
|
+
EOB
|
185
|
+
),
|
186
|
+
_format(tokens)
|
187
|
+
)
|
157
188
|
end
|
158
189
|
|
159
190
|
|
@@ -163,26 +194,30 @@ EOB
|
|
163
194
|
########
|
164
195
|
tokens = @parser.parse("a=")
|
165
196
|
@fmt.insert_space_between_tokens(tokens)
|
166
|
-
assert_equals(msg,
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
197
|
+
assert_equals(msg,
|
198
|
+
strip_indent(
|
199
|
+
<<-EOB
|
200
|
+
name (a)
|
201
|
+
space ( )
|
202
|
+
symbol (=)
|
203
|
+
EOB
|
204
|
+
),
|
205
|
+
_format(tokens)
|
206
|
+
)
|
174
207
|
|
175
208
|
########
|
176
209
|
tokens = @parser.parse("=b")
|
177
210
|
@fmt.insert_space_between_tokens(tokens)
|
178
|
-
assert_equals(msg,
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
211
|
+
assert_equals(msg,
|
212
|
+
strip_indent(
|
213
|
+
<<-EOB
|
214
|
+
symbol (=)
|
215
|
+
space ( )
|
216
|
+
name (b)
|
217
|
+
EOB
|
218
|
+
),
|
219
|
+
_format(tokens)
|
220
|
+
)
|
186
221
|
end
|
187
222
|
|
188
223
|
|
@@ -194,26 +229,31 @@ EOB
|
|
194
229
|
|
195
230
|
index, indent_depth = 1, 1
|
196
231
|
|
197
|
-
assert_equals(
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
232
|
+
assert_equals(
|
233
|
+
msg + "before",
|
234
|
+
strip_indent(
|
235
|
+
<<-EOB
|
236
|
+
name (foo)
|
237
|
+
space ( )
|
238
|
+
name (bar)
|
239
|
+
EOB
|
240
|
+
),
|
241
|
+
_format(tokens)
|
242
|
+
)
|
205
243
|
|
206
244
|
result = @fmt.insert_return_and_indent(tokens, index, indent_depth)
|
207
245
|
|
208
|
-
assert_equals(
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
246
|
+
assert_equals(
|
247
|
+
msg + "index: #{index} / indent depth: #{indent_depth}",
|
248
|
+
strip_indent(
|
249
|
+
<<-EOB
|
250
|
+
name (foo)
|
251
|
+
space (\n#{INDENT_STR})
|
252
|
+
name (bar)
|
253
|
+
EOB
|
254
|
+
),
|
255
|
+
_format(tokens)
|
256
|
+
)
|
217
257
|
|
218
258
|
########
|
219
259
|
# msg = "" #"後の空白を置き換え"
|
@@ -221,112 +261,134 @@ EOB
|
|
221
261
|
|
222
262
|
index, indent_depth = 1, 1
|
223
263
|
|
224
|
-
assert_equals(
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
264
|
+
assert_equals(
|
265
|
+
msg + "before",
|
266
|
+
strip_indent(
|
267
|
+
<<-EOB
|
268
|
+
keyword (select)
|
269
|
+
space ( )
|
270
|
+
name (foo)
|
271
|
+
EOB
|
272
|
+
),
|
273
|
+
_format(tokens)
|
274
|
+
)
|
232
275
|
|
233
276
|
result = @fmt.insert_return_and_indent(tokens, index, indent_depth)
|
234
277
|
|
235
|
-
assert_equals(
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
278
|
+
assert_equals(
|
279
|
+
msg + "#{msg}: index: #{index} / indent depth: #{indent_depth}",
|
280
|
+
strip_indent(
|
281
|
+
<<-EOB
|
282
|
+
keyword (select)
|
283
|
+
space (\n#{INDENT_STR})
|
284
|
+
name (foo)
|
285
|
+
EOB
|
286
|
+
),
|
287
|
+
_format(tokens)
|
288
|
+
)
|
244
289
|
|
245
290
|
########
|
246
291
|
msg = "" #"前の空白を置き換え"
|
247
292
|
tokens = @parser.parse("select foo")
|
248
293
|
index, indent_depth = 2, 1
|
249
294
|
|
250
|
-
assert_equals(
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
295
|
+
assert_equals(
|
296
|
+
msg + "before",
|
297
|
+
strip_indent(
|
298
|
+
<<-EOB
|
299
|
+
keyword (select)
|
300
|
+
space ( )
|
301
|
+
name (foo)
|
302
|
+
EOB
|
303
|
+
),
|
304
|
+
_format(tokens)
|
305
|
+
)
|
258
306
|
|
259
307
|
result = @fmt.insert_return_and_indent(tokens, index, indent_depth)
|
260
|
-
assert_equals(
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
308
|
+
assert_equals(
|
309
|
+
msg + "", 0, result)
|
310
|
+
|
311
|
+
assert_equals(
|
312
|
+
msg + "#{msg}: index: #{index} / indent depth: #{indent_depth}",
|
313
|
+
strip_indent(
|
314
|
+
<<-EOB
|
315
|
+
keyword (select)
|
316
|
+
space (\n#{INDENT_STR})
|
317
|
+
name (foo)
|
318
|
+
EOB
|
319
|
+
),
|
320
|
+
_format(tokens)
|
321
|
+
)
|
271
322
|
|
272
323
|
########
|
273
324
|
msg = "indent depth = 2"
|
274
325
|
tokens = @parser.parse("foo bar")
|
275
326
|
index, indent_depth = 1, 2
|
276
327
|
|
277
|
-
assert_equals(
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
328
|
+
assert_equals(
|
329
|
+
msg + "before",
|
330
|
+
strip_indent(
|
331
|
+
<<-EOB
|
332
|
+
name (foo)
|
333
|
+
space ( )
|
334
|
+
name (bar)
|
335
|
+
EOB
|
336
|
+
),
|
337
|
+
_format(tokens)
|
338
|
+
)
|
285
339
|
|
286
340
|
result = @fmt.insert_return_and_indent(tokens, index, indent_depth)
|
287
341
|
|
288
|
-
assert_equals(
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
342
|
+
assert_equals(
|
343
|
+
msg + "#{msg}: index: #{index} / indent depth: #{indent_depth}",
|
344
|
+
strip_indent(
|
345
|
+
<<-EOB
|
346
|
+
name (foo)
|
347
|
+
space (\n#{INDENT_STR}#{INDENT_STR})
|
348
|
+
name (bar)
|
349
|
+
EOB
|
350
|
+
),
|
351
|
+
_format(tokens)
|
352
|
+
)
|
297
353
|
|
298
354
|
########
|
299
355
|
msg = "kw, nl, kw"
|
300
356
|
tokens = @parser.parse("select\ncase")
|
301
357
|
|
302
|
-
assert_equals(
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
358
|
+
assert_equals(
|
359
|
+
msg + "",
|
360
|
+
strip_indent(
|
361
|
+
<<-EOB
|
362
|
+
keyword (select)
|
363
|
+
space (\n)
|
364
|
+
keyword (case)
|
365
|
+
EOB
|
366
|
+
),
|
367
|
+
_format(tokens)
|
368
|
+
)
|
310
369
|
|
311
370
|
########
|
312
371
|
=begin
|
313
372
|
msg = "FROM の前で改行"
|
314
373
|
|
315
|
-
assert_equals(
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
<-indent-><-indent
|
321
|
-
<-indent-><-indent->,
|
322
|
-
<-indent
|
323
|
-
<-indent-><-indent
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
374
|
+
assert_equals(
|
375
|
+
msg + "",
|
376
|
+
strip_indent(
|
377
|
+
<<-EOB
|
378
|
+
SELECT
|
379
|
+
<-indent-><-indent->aa
|
380
|
+
<-indent-><-indent->,bb
|
381
|
+
<-indent-><-indent->,cc
|
382
|
+
<-indent-><-indent->,dd
|
383
|
+
<-indent-><-indent->,ee
|
384
|
+
<-indent->FROM
|
385
|
+
<-indent-><-indent->foo
|
386
|
+
;
|
387
|
+
EOB
|
388
|
+
),
|
389
|
+
# _format(tokens),
|
390
|
+
@fmt.format("SELECT aa ,bb ,cc ,dd ,ee FROM foo;")
|
391
|
+
)
|
330
392
|
=end
|
331
393
|
|
332
394
|
# ########
|
@@ -337,7 +399,7 @@ EOB
|
|
337
399
|
# index = 1
|
338
400
|
# result = @fmt.insert_return_and_indent(tokens, index, 1)
|
339
401
|
|
340
|
-
# assert_equals(
|
402
|
+
# assert_equals(msg + "", 1, result, msg)
|
341
403
|
|
342
404
|
########
|
343
405
|
msg = "指定した index に対して tokens[index] が存在しないので 0 を返すべき"
|
@@ -346,7 +408,7 @@ EOB
|
|
346
408
|
index = 10
|
347
409
|
result = @fmt.insert_return_and_indent(tokens, index, 1)
|
348
410
|
|
349
|
-
assert_equals(
|
411
|
+
assert_equals(msg + "", 0, result)
|
350
412
|
end ## insert_return_and_indent
|
351
413
|
|
352
414
|
|
@@ -357,69 +419,84 @@ EOB
|
|
357
419
|
func_name = "TEST_FUNCTION"
|
358
420
|
@rule.function_names << func_name
|
359
421
|
|
360
|
-
assert_equals(
|
361
|
-
|
362
|
-
|
363
|
-
EOB
|
364
|
-
|
365
|
-
|
366
|
-
|
422
|
+
assert_equals(
|
423
|
+
msg + "function with parenthesis",
|
424
|
+
strip_indent(
|
425
|
+
<<-EOB
|
426
|
+
SELECT
|
427
|
+
<-indent-><-indent->#{func_name}( * )
|
428
|
+
EOB
|
429
|
+
),
|
430
|
+
@fmt.format("select #{func_name}(*)")
|
431
|
+
)
|
367
432
|
|
368
433
|
@rule.function_names.delete func_name
|
369
434
|
|
370
435
|
########
|
371
|
-
assert_equals(
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
EOB
|
382
|
-
|
383
|
-
|
436
|
+
assert_equals(
|
437
|
+
msg + "Next line of single commnet",
|
438
|
+
strip_indent(
|
439
|
+
<<-EOB
|
440
|
+
SELECT
|
441
|
+
<-indent-><-indent->-- comment
|
442
|
+
<-indent-><-indent->name
|
443
|
+
EOB
|
444
|
+
),
|
445
|
+
@fmt.format(strip_indent(
|
446
|
+
<<-EOB
|
447
|
+
select
|
448
|
+
-- comment
|
449
|
+
name
|
450
|
+
EOB
|
451
|
+
))
|
452
|
+
)
|
384
453
|
|
385
454
|
########
|
386
|
-
assert_equals(
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
EOB
|
396
|
-
|
397
|
-
|
455
|
+
assert_equals(
|
456
|
+
msg + "new line after single line comment",
|
457
|
+
strip_indent(
|
458
|
+
<<-EOB
|
459
|
+
--a
|
460
|
+
b
|
461
|
+
EOB
|
462
|
+
),
|
463
|
+
@fmt.format(strip_indent(
|
464
|
+
<<-EOB
|
465
|
+
--a
|
466
|
+
b
|
467
|
+
EOB
|
468
|
+
))
|
469
|
+
);
|
398
470
|
|
399
471
|
########
|
400
|
-
assert_equals(
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
472
|
+
assert_equals(
|
473
|
+
msg + "two line breaks after semicolon",
|
474
|
+
strip_indent(
|
475
|
+
<<-EOB
|
476
|
+
a
|
477
|
+
;
|
478
|
+
|
479
|
+
b
|
480
|
+
EOB
|
481
|
+
),
|
482
|
+
@fmt.format(strip_indent(
|
483
|
+
<<-EOB
|
484
|
+
a;b
|
485
|
+
EOB
|
486
|
+
))
|
487
|
+
);
|
413
488
|
|
414
489
|
########
|
415
|
-
assert_equals(
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
490
|
+
assert_equals(
|
491
|
+
msg + "two line breaks after semicolon",
|
492
|
+
strip_indent(
|
493
|
+
<<-EOB
|
494
|
+
a
|
495
|
+
;
|
496
|
+
EOB
|
497
|
+
),
|
498
|
+
@fmt.format("a;")
|
499
|
+
)
|
423
500
|
end
|
424
501
|
|
425
502
|
|
@@ -429,61 +506,71 @@ EOB
|
|
429
506
|
########
|
430
507
|
tokens = @parser.parse("a;b")
|
431
508
|
|
432
|
-
assert_equals(
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
509
|
+
assert_equals(
|
510
|
+
msg + "first statement",
|
511
|
+
"a",
|
512
|
+
@fmt.split_by_semicolon(tokens)[0][0].string
|
513
|
+
)
|
514
|
+
assert_equals(
|
515
|
+
msg + "second statement",
|
516
|
+
"b",
|
517
|
+
@fmt.split_by_semicolon(tokens)[1][0].string
|
518
|
+
)
|
440
519
|
|
441
520
|
########
|
442
521
|
tokens = @parser.parse(";")
|
443
522
|
statements = @fmt.split_by_semicolon(tokens)
|
444
|
-
assert_equals(
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
523
|
+
assert_equals(
|
524
|
+
msg,
|
525
|
+
[],
|
526
|
+
statements[0]
|
527
|
+
)
|
528
|
+
assert_equals(
|
529
|
+
msg,
|
530
|
+
[],
|
531
|
+
statements[1]
|
532
|
+
)
|
452
533
|
|
453
534
|
########
|
454
535
|
tokens = @parser.parse("a;")
|
455
536
|
statements = @fmt.split_by_semicolon(tokens)
|
456
|
-
assert_equals(
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
537
|
+
assert_equals(
|
538
|
+
msg,
|
539
|
+
"name (a)",
|
540
|
+
_format( statements[0] )
|
541
|
+
)
|
542
|
+
assert_equals(
|
543
|
+
msg,
|
544
|
+
[],
|
545
|
+
statements[1]
|
546
|
+
)
|
464
547
|
|
465
548
|
########
|
466
549
|
tokens = @parser.parse(";a")
|
467
550
|
statements = @fmt.split_by_semicolon(tokens)
|
468
|
-
assert_equals(
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
551
|
+
assert_equals(
|
552
|
+
msg,
|
553
|
+
[],
|
554
|
+
statements[0]
|
555
|
+
)
|
556
|
+
assert_equals(
|
557
|
+
msg,
|
558
|
+
"name (a)",
|
559
|
+
_format( statements[1] )
|
560
|
+
)
|
476
561
|
|
477
562
|
########
|
478
563
|
tokens = @parser.parse("a;b")
|
479
564
|
statements = @fmt.split_by_semicolon(tokens)
|
480
|
-
assert_equals(
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
565
|
+
assert_equals(
|
566
|
+
msg,
|
567
|
+
"name (a)",
|
568
|
+
_format( statements[0] )
|
569
|
+
)
|
570
|
+
assert_equals(
|
571
|
+
msg,
|
572
|
+
"name (b)",
|
573
|
+
_format( statements[1] )
|
574
|
+
)
|
488
575
|
end
|
489
576
|
end
|