comment_strip-ruby 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/comment_strip/language_families/c.rb +159 -137
- data/lib/comment_strip/language_families/hash_line.rb +211 -0
- data/lib/comment_strip/strip.rb +24 -12
- data/lib/comment_strip/version.rb +7 -8
- data/test/unit/{tc_strip.rb → tc_strip_c.rb} +262 -232
- data/test/unit/tc_strip_hash_line.rb +95 -0
- data/test/unit/ts_all.rb +1 -1
- metadata +16 -15
@@ -9,63 +9,63 @@ require 'xqsr3/extensions/test/unit'
|
|
9
9
|
|
10
10
|
require 'test/unit'
|
11
11
|
|
12
|
-
class
|
12
|
+
class Test_C_strip_1 < Test::Unit::TestCase
|
13
13
|
|
14
|
-
|
14
|
+
include ::CommentStrip
|
15
15
|
|
16
|
-
|
16
|
+
def test_nil
|
17
17
|
|
18
|
-
|
18
|
+
assert_nil strip(nil, 'C')
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
assert_nil ::CommentStrip.strip(nil, 'C')
|
21
|
+
end
|
22
22
|
|
23
|
-
|
23
|
+
def test_unrecognised_families
|
24
24
|
|
25
|
-
|
25
|
+
unrecognised_families = %w{
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
Python
|
28
|
+
Perl
|
29
|
+
Ruby
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
Java
|
32
|
+
Kotlin
|
33
|
+
Scala
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
Rust
|
36
|
+
}
|
37
37
|
|
38
|
-
|
38
|
+
unrecognised_families.each do |family|
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
40
|
+
assert_raise_with_message(::RuntimeError, /family.*unrecognised/) { strip('', family) }
|
41
|
+
assert_raise_with_message(::RuntimeError, /family.*unrecognised/) { ::CommentStrip.strip('', family) }
|
43
42
|
end
|
43
|
+
end
|
44
44
|
|
45
|
-
|
45
|
+
def test_empty
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
assert_equal "", strip('', 'C')
|
48
|
+
assert_equal "", ::CommentStrip.strip('', :C)
|
49
|
+
end
|
50
50
|
|
51
|
-
|
51
|
+
def test_simple_main
|
52
52
|
|
53
|
-
|
53
|
+
input = <<-EOF_main
|
54
54
|
#include <stdio.h>
|
55
55
|
int main(int argc, char* argv[])
|
56
56
|
{
|
57
57
|
return 0;
|
58
58
|
}
|
59
59
|
EOF_main
|
60
|
-
|
60
|
+
expected = input
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
assert_equal expected, strip(input, 'C')
|
63
|
+
assert_equal expected, ::CommentStrip.strip(input, 'C')
|
64
|
+
end
|
65
65
|
|
66
|
-
|
66
|
+
def test_x_1
|
67
67
|
|
68
|
-
|
68
|
+
input = <<-EOF_main
|
69
69
|
#ifdef CLARA_PLATFORM_WINDOWS
|
70
70
|
case '/': from = i+1; return SlashOpt;
|
71
71
|
#endif
|
@@ -78,7 +78,7 @@ EOF_main
|
|
78
78
|
return !placeholder.empty();
|
79
79
|
}
|
80
80
|
EOF_main
|
81
|
-
|
81
|
+
expected = <<-EOF_main
|
82
82
|
#ifdef CLARA_PLATFORM_WINDOWS
|
83
83
|
case '/': from = i+1; return SlashOpt;
|
84
84
|
#endif
|
@@ -92,232 +92,232 @@ EOF_main
|
|
92
92
|
}
|
93
93
|
EOF_main
|
94
94
|
|
95
|
-
|
96
|
-
|
95
|
+
actual = strip(input, 'C')
|
96
|
+
actual = ::CommentStrip.strip(input, 'C')
|
97
97
|
|
98
|
-
|
99
|
-
|
98
|
+
assert_equal expected, actual
|
99
|
+
end
|
100
100
|
|
101
|
-
|
101
|
+
def test_x_2
|
102
102
|
|
103
|
-
|
103
|
+
input = <<-EOF_main
|
104
104
|
|
105
105
|
} // namespace something
|
106
106
|
EOF_main
|
107
|
-
|
107
|
+
expected = <<-EOF_main
|
108
108
|
|
109
109
|
}
|
110
110
|
EOF_main
|
111
111
|
|
112
|
-
|
113
|
-
|
112
|
+
actual = strip(input, 'C')
|
113
|
+
actual = ::CommentStrip.strip(input, 'C')
|
114
114
|
|
115
|
-
|
116
|
-
|
115
|
+
assert_equal expected, actual
|
116
|
+
end
|
117
117
|
|
118
|
-
|
118
|
+
def test_x_3
|
119
119
|
|
120
|
-
|
120
|
+
input = <<-EOF_main
|
121
121
|
|
122
122
|
#endif /* !LOG_PERROR */
|
123
123
|
EOF_main
|
124
|
-
|
124
|
+
expected = <<-EOF_main
|
125
125
|
|
126
126
|
#endif
|
127
127
|
EOF_main
|
128
128
|
|
129
|
-
|
130
|
-
|
129
|
+
actual = strip(input, 'C')
|
130
|
+
actual = ::CommentStrip.strip(input, 'C')
|
131
131
|
|
132
|
-
|
133
|
-
|
132
|
+
assert_equal expected, actual
|
133
|
+
end
|
134
134
|
|
135
|
-
|
135
|
+
def test_code_with_single_quoted_characters_1
|
136
136
|
|
137
|
-
|
137
|
+
input = <<-EOF_main
|
138
138
|
|
139
139
|
case '"': // " this is the comment "
|
140
140
|
EOF_main
|
141
|
-
|
141
|
+
expected = <<-EOF_main
|
142
142
|
|
143
143
|
case '"':
|
144
144
|
EOF_main
|
145
145
|
|
146
|
-
|
146
|
+
actual = strip(input, 'C')
|
147
147
|
|
148
|
-
|
149
|
-
|
148
|
+
assert_equal expected, actual
|
149
|
+
end
|
150
150
|
|
151
|
-
|
151
|
+
def test_code_with_single_quoted_characters_2
|
152
152
|
|
153
|
-
|
153
|
+
input = <<-EOF_main
|
154
154
|
|
155
|
-
case '
|
155
|
+
case '\"': // " this is the comment "
|
156
156
|
EOF_main
|
157
|
-
|
157
|
+
expected = <<-EOF_main
|
158
158
|
|
159
|
-
case '
|
159
|
+
case '\"':
|
160
160
|
EOF_main
|
161
161
|
|
162
|
-
|
162
|
+
actual = strip(input, 'C')
|
163
163
|
|
164
|
-
|
165
|
-
|
164
|
+
assert_equal expected, actual
|
165
|
+
end
|
166
166
|
|
167
|
-
|
167
|
+
def test_code_with_single_quoted_characters_3
|
168
168
|
|
169
|
-
|
169
|
+
input = <<-EOF_main
|
170
170
|
|
171
|
-
case '
|
171
|
+
case '\'': // " this is the comment "
|
172
172
|
EOF_main
|
173
|
-
|
173
|
+
expected = <<-EOF_main
|
174
174
|
|
175
|
-
case '
|
175
|
+
case '\'':
|
176
176
|
EOF_main
|
177
177
|
|
178
|
-
|
178
|
+
actual = strip(input, 'C')
|
179
179
|
|
180
|
-
|
181
|
-
|
180
|
+
assert_equal expected, actual
|
181
|
+
end
|
182
182
|
|
183
|
-
|
183
|
+
def test_code_with_single_quoted_characters_4
|
184
184
|
|
185
|
-
|
185
|
+
input = <<-EOF_main
|
186
186
|
|
187
187
|
case '\\\\': // " this is the comment "
|
188
188
|
EOF_main
|
189
|
-
|
189
|
+
expected = <<-EOF_main
|
190
190
|
|
191
191
|
case '\\\\':
|
192
192
|
EOF_main
|
193
193
|
|
194
|
-
|
194
|
+
actual = strip(input, 'C')
|
195
195
|
|
196
|
-
|
197
|
-
|
196
|
+
assert_equal expected, actual
|
197
|
+
end
|
198
198
|
|
199
|
-
|
199
|
+
def test_code_with_single_quoted_characters_5
|
200
200
|
|
201
|
-
|
201
|
+
input = <<-EOF_main
|
202
202
|
|
203
203
|
case '\\\\': // " this is the comment "
|
204
204
|
EOF_main
|
205
|
-
|
205
|
+
expected = <<-EOF_main
|
206
206
|
|
207
207
|
case '\\\\':
|
208
208
|
EOF_main
|
209
209
|
|
210
|
-
|
210
|
+
actual = strip(input, 'C')
|
211
211
|
|
212
|
-
|
213
|
-
|
212
|
+
assert_equal expected, actual
|
213
|
+
end
|
214
214
|
|
215
|
-
|
215
|
+
def test_code_with_single_quoted_characters_6
|
216
216
|
|
217
|
-
|
217
|
+
input = <<-EOF_main
|
218
218
|
|
219
219
|
#define SOME_CHAR '\\x80' /* some char */
|
220
220
|
EOF_main
|
221
|
-
|
221
|
+
expected = <<-EOF_main
|
222
222
|
|
223
223
|
#define SOME_CHAR '\\x80'
|
224
224
|
EOF_main
|
225
225
|
|
226
|
-
|
226
|
+
actual = strip(input, 'C')
|
227
227
|
|
228
|
-
|
229
|
-
|
228
|
+
assert_equal expected, actual
|
229
|
+
end
|
230
230
|
|
231
|
-
|
231
|
+
def test_code_with_double_quoted_characters_1
|
232
232
|
|
233
|
-
|
233
|
+
input = <<-EOF_main
|
234
234
|
|
235
235
|
case "'": // " this is the comment "
|
236
236
|
EOF_main
|
237
|
-
|
237
|
+
expected = <<-EOF_main
|
238
238
|
|
239
239
|
case "'":
|
240
240
|
EOF_main
|
241
241
|
|
242
|
-
|
242
|
+
actual = strip(input, 'C')
|
243
243
|
|
244
|
-
|
245
|
-
|
244
|
+
assert_equal expected, actual
|
245
|
+
end
|
246
246
|
|
247
|
-
|
247
|
+
def test_code_with_double_quoted_characters_2
|
248
248
|
|
249
|
-
|
249
|
+
input = <<-EOF_main
|
250
250
|
|
251
251
|
case "\\"": // " this is the comment "
|
252
252
|
EOF_main
|
253
|
-
|
253
|
+
expected = <<-EOF_main
|
254
254
|
|
255
255
|
case "\\"":
|
256
256
|
EOF_main
|
257
257
|
|
258
|
-
|
258
|
+
actual = strip(input, 'C')
|
259
259
|
|
260
|
-
|
261
|
-
|
260
|
+
assert_equal expected, actual
|
261
|
+
end
|
262
262
|
|
263
|
-
|
263
|
+
def test_code_with_double_quoted_characters_3
|
264
264
|
|
265
|
-
|
265
|
+
input = <<-EOF_main
|
266
266
|
|
267
267
|
case "\\'": // " this is the comment "
|
268
268
|
EOF_main
|
269
|
-
|
269
|
+
expected = <<-EOF_main
|
270
270
|
|
271
271
|
case "\\'":
|
272
272
|
EOF_main
|
273
273
|
|
274
|
-
|
274
|
+
actual = strip(input, 'C')
|
275
275
|
|
276
|
-
|
277
|
-
|
276
|
+
assert_equal expected, actual
|
277
|
+
end
|
278
278
|
|
279
|
-
|
279
|
+
def test_code_with_double_quoted_characters_4
|
280
280
|
|
281
|
-
|
281
|
+
input = <<-EOF_main
|
282
282
|
|
283
283
|
case "\\\\": // " this is the comment "
|
284
284
|
EOF_main
|
285
|
-
|
285
|
+
expected = <<-EOF_main
|
286
286
|
|
287
287
|
case "\\\\":
|
288
288
|
EOF_main
|
289
289
|
|
290
|
-
|
290
|
+
actual = strip(input, 'C')
|
291
291
|
|
292
|
-
|
293
|
-
|
292
|
+
assert_equal expected, actual
|
293
|
+
end
|
294
294
|
|
295
|
-
|
295
|
+
def test_code_with_double_quoted_characters_5
|
296
296
|
|
297
|
-
|
297
|
+
input = <<-EOF_main
|
298
298
|
|
299
299
|
case "\\\\": // " this is the comment "
|
300
300
|
EOF_main
|
301
|
-
|
301
|
+
expected = <<-EOF_main
|
302
302
|
|
303
303
|
case "\\\\":
|
304
304
|
EOF_main
|
305
305
|
|
306
|
-
|
306
|
+
actual = strip(input, 'C')
|
307
307
|
|
308
|
-
|
309
|
-
|
308
|
+
assert_equal expected, actual
|
309
|
+
end
|
310
310
|
|
311
|
-
|
311
|
+
def test_simple_main_with_trailing_cppcomment
|
312
312
|
|
313
|
-
|
313
|
+
input = <<-EOF_main
|
314
314
|
#include <stdio.h>
|
315
315
|
int main(int argc, char* argv[])
|
316
316
|
{
|
317
317
|
return 0; // same as EXIT_SUCCESS
|
318
318
|
}
|
319
319
|
EOF_main
|
320
|
-
|
320
|
+
expected = <<-EOF_main
|
321
321
|
#include <stdio.h>
|
322
322
|
int main(int argc, char* argv[])
|
323
323
|
{
|
@@ -325,19 +325,19 @@ int main(int argc, char* argv[])
|
|
325
325
|
}
|
326
326
|
EOF_main
|
327
327
|
|
328
|
-
|
329
|
-
|
328
|
+
assert_equal expected, strip(input, 'C')
|
329
|
+
end
|
330
330
|
|
331
|
-
|
331
|
+
def test_simple_main_with_trailing_cppcomment_and_divide_maths
|
332
332
|
|
333
|
-
|
333
|
+
input = <<-EOF_main
|
334
334
|
#include <stdio.h>
|
335
335
|
int main(int argc, char* argv[])
|
336
336
|
{
|
337
337
|
return 0 / 1; // same as EXIT_SUCCESS
|
338
338
|
}
|
339
339
|
EOF_main
|
340
|
-
|
340
|
+
expected = <<-EOF_main
|
341
341
|
#include <stdio.h>
|
342
342
|
int main(int argc, char* argv[])
|
343
343
|
{
|
@@ -345,19 +345,19 @@ int main(int argc, char* argv[])
|
|
345
345
|
}
|
346
346
|
EOF_main
|
347
347
|
|
348
|
-
|
349
|
-
|
348
|
+
assert_equal expected, strip(input, 'C')
|
349
|
+
end
|
350
350
|
|
351
|
-
|
351
|
+
def test_simple_main_with_ccomment
|
352
352
|
|
353
|
-
|
353
|
+
input = <<-EOF_main
|
354
354
|
#include <stdio.h>
|
355
355
|
int main(int argc, char* argv[])
|
356
356
|
{
|
357
357
|
return 2; /* same as EXIT_SUCCESS */
|
358
358
|
}
|
359
359
|
EOF_main
|
360
|
-
|
360
|
+
expected = <<-EOF_main
|
361
361
|
#include <stdio.h>
|
362
362
|
int main(int argc, char* argv[])
|
363
363
|
{
|
@@ -365,38 +365,38 @@ int main(int argc, char* argv[])
|
|
365
365
|
}
|
366
366
|
EOF_main
|
367
367
|
|
368
|
-
|
369
|
-
|
368
|
+
assert_equal expected, strip(input, 'C')
|
369
|
+
end
|
370
370
|
|
371
|
-
|
371
|
+
def test_ccomment_inline
|
372
372
|
|
373
|
-
|
374
|
-
|
373
|
+
input = 'int i = func(/*x=*/x, /*y=*/y);'
|
374
|
+
expected = 'int i = func(x, y);'
|
375
375
|
|
376
|
-
|
377
|
-
|
376
|
+
assert_equal expected, strip(input, 'C')
|
377
|
+
end
|
378
378
|
|
379
|
-
|
379
|
+
def test_multiline_1
|
380
380
|
|
381
|
-
|
381
|
+
input = <<-EOF_main
|
382
382
|
|
383
383
|
/** Some function description
|
384
384
|
*/
|
385
385
|
int func();
|
386
386
|
EOF_main
|
387
|
-
|
387
|
+
expected = <<-EOF_main
|
388
388
|
|
389
389
|
|
390
390
|
|
391
391
|
int func();
|
392
392
|
EOF_main
|
393
393
|
|
394
|
-
|
395
|
-
|
394
|
+
assert_equal expected, strip(input, 'C')
|
395
|
+
end
|
396
396
|
|
397
|
-
|
397
|
+
def test_multiline_2
|
398
398
|
|
399
|
-
|
399
|
+
input = <<-EOF_main
|
400
400
|
|
401
401
|
/** Some function description
|
402
402
|
*/
|
@@ -408,7 +408,7 @@ int func();
|
|
408
408
|
|
409
409
|
int fn();
|
410
410
|
EOF_main
|
411
|
-
|
411
|
+
expected = <<-EOF_main
|
412
412
|
|
413
413
|
|
414
414
|
|
@@ -421,12 +421,12 @@ int func();
|
|
421
421
|
int fn();
|
422
422
|
EOF_main
|
423
423
|
|
424
|
-
|
425
|
-
|
424
|
+
assert_equal expected, strip(input, 'C')
|
425
|
+
end
|
426
426
|
|
427
|
-
|
427
|
+
def test_multiline_3
|
428
428
|
|
429
|
-
|
429
|
+
input = <<-EOF_main
|
430
430
|
|
431
431
|
/** Some function description
|
432
432
|
*
|
@@ -434,7 +434,7 @@ EOF_main
|
|
434
434
|
*/
|
435
435
|
int func();
|
436
436
|
EOF_main
|
437
|
-
|
437
|
+
expected = <<-EOF_main
|
438
438
|
|
439
439
|
|
440
440
|
|
@@ -443,12 +443,12 @@ EOF_main
|
|
443
443
|
int func();
|
444
444
|
EOF_main
|
445
445
|
|
446
|
-
|
447
|
-
|
446
|
+
assert_equal expected, strip(input, 'C')
|
447
|
+
end
|
448
448
|
|
449
|
-
|
449
|
+
def test_multiline_4
|
450
450
|
|
451
|
-
|
451
|
+
input = <<-EOF_main
|
452
452
|
|
453
453
|
/** //////////////////////////////////
|
454
454
|
*
|
@@ -465,42 +465,72 @@ EOF_main
|
|
465
465
|
int func();
|
466
466
|
EOF_main
|
467
467
|
|
468
|
-
|
469
|
-
|
468
|
+
assert_equal expected, strip(input, 'C')
|
469
|
+
end
|
470
470
|
|
471
|
-
|
471
|
+
def test_comments_in_strings_1
|
472
472
|
|
473
|
-
|
473
|
+
input = <<-EOF_main
|
474
474
|
|
475
475
|
string s("//"); // THIS is the comment
|
476
476
|
EOF_main
|
477
|
-
|
477
|
+
expected = <<-EOF_main
|
478
478
|
|
479
479
|
string s("//");
|
480
480
|
EOF_main
|
481
|
-
|
481
|
+
actual = strip(input, 'C')
|
482
482
|
|
483
|
-
|
484
|
-
|
483
|
+
assert_equal expected, actual
|
484
|
+
end
|
485
485
|
|
486
|
-
|
486
|
+
def test_comments_in_strings_2
|
487
487
|
|
488
|
-
|
488
|
+
input = <<-EOF_main
|
489
489
|
|
490
490
|
string s("/*"); // THIS is the comment
|
491
491
|
EOF_main
|
492
|
-
|
492
|
+
expected = <<-EOF_main
|
493
493
|
|
494
494
|
string s("/*");
|
495
495
|
EOF_main
|
496
|
-
|
496
|
+
actual = strip(input, 'C')
|
497
497
|
|
498
|
-
|
499
|
-
|
498
|
+
assert_equal expected, actual
|
499
|
+
end
|
500
|
+
|
501
|
+
def test_comments_in_strings_3
|
502
|
+
|
503
|
+
input = <<-EOF_main
|
504
|
+
|
505
|
+
string s("/"); // THIS is the comment
|
506
|
+
EOF_main
|
507
|
+
expected = <<-EOF_main
|
508
|
+
|
509
|
+
string s("/");
|
510
|
+
EOF_main
|
511
|
+
actual = strip(input, 'C')
|
512
|
+
|
513
|
+
assert_equal expected, actual
|
514
|
+
end
|
515
|
+
|
516
|
+
def test_comments_in_strings_4
|
517
|
+
|
518
|
+
input = <<-EOF_main
|
519
|
+
|
520
|
+
string s("/* this is a comment */"); // this is THE comment
|
521
|
+
EOF_main
|
522
|
+
expected = <<-EOF_main
|
523
|
+
|
524
|
+
string s("/* this is a comment */");
|
525
|
+
EOF_main
|
526
|
+
actual = strip(input, 'C')
|
500
527
|
|
501
|
-
|
528
|
+
assert_equal expected, actual
|
529
|
+
end
|
502
530
|
|
503
|
-
|
531
|
+
def test_real_sample_1
|
532
|
+
|
533
|
+
input = <<-EOF_main
|
504
534
|
/* /////////////////////////////////////////////////////////////////////////
|
505
535
|
* includes
|
506
536
|
*
|
@@ -531,7 +561,7 @@ EOF_main
|
|
531
561
|
# pragma warning(disable : 4702) // suppresses "unreachable code"
|
532
562
|
#endif /* compiler */
|
533
563
|
EOF_main
|
534
|
-
|
564
|
+
expected = <<-EOF_main
|
535
565
|
|
536
566
|
|
537
567
|
|
@@ -562,14 +592,14 @@ EOF_main
|
|
562
592
|
# pragma warning(disable : 4702)
|
563
593
|
#endif
|
564
594
|
EOF_main
|
565
|
-
|
595
|
+
actual = strip(input, 'C')
|
566
596
|
|
567
|
-
|
568
|
-
|
597
|
+
assert_equal expected, actual
|
598
|
+
end
|
569
599
|
|
570
|
-
|
600
|
+
def test_real_sample_2
|
571
601
|
|
572
|
-
|
602
|
+
input = <<-EOF_main
|
573
603
|
/* /////////////////////////////////////////////////////////////////////////
|
574
604
|
* includes
|
575
605
|
*/
|
@@ -616,7 +646,7 @@ EOF_main
|
|
616
646
|
# include <crtdbg.h>
|
617
647
|
#endif
|
618
648
|
EOF_main
|
619
|
-
|
649
|
+
expected = <<-EOF_main
|
620
650
|
|
621
651
|
|
622
652
|
|
@@ -664,12 +694,12 @@ EOF_main
|
|
664
694
|
#endif
|
665
695
|
EOF_main
|
666
696
|
|
667
|
-
|
668
|
-
|
697
|
+
assert_equal expected, strip(input, 'C')
|
698
|
+
end
|
669
699
|
|
670
|
-
|
700
|
+
def test_real_sample_3
|
671
701
|
|
672
|
-
|
702
|
+
input = <<-EOF_main
|
673
703
|
/* /////////////////////////////////////////////////////////////////////////
|
674
704
|
* File: src/fmt_cache.cpp
|
675
705
|
*
|
@@ -752,7 +782,7 @@ EOF_main
|
|
752
782
|
#include <new>
|
753
783
|
EOF_main
|
754
784
|
|
755
|
-
|
785
|
+
expected = <<-EOF_main
|
756
786
|
|
757
787
|
|
758
788
|
|
@@ -835,14 +865,14 @@ EOF_main
|
|
835
865
|
#include <new>
|
836
866
|
EOF_main
|
837
867
|
|
838
|
-
|
868
|
+
actual = strip(input, 'C')
|
839
869
|
|
840
|
-
|
841
|
-
|
870
|
+
assert_equal expected, strip(input, 'C')
|
871
|
+
end
|
842
872
|
|
843
|
-
|
873
|
+
def test_real_sample_4
|
844
874
|
|
845
|
-
|
875
|
+
input = <<-EOF_main
|
846
876
|
/* /////////////////////////////////////////////////////////////////////////
|
847
877
|
* File: src/fmt_cache.cpp
|
848
878
|
*
|
@@ -1547,7 +1577,7 @@ pattern_t pattern_record_t::pattern() const
|
|
1547
1577
|
/* ///////////////////////////// end of file //////////////////////////// */
|
1548
1578
|
EOF_main
|
1549
1579
|
|
1550
|
-
|
1580
|
+
expected = <<-EOF_main
|
1551
1581
|
|
1552
1582
|
|
1553
1583
|
|
@@ -2252,12 +2282,12 @@ pattern_t pattern_record_t::pattern() const
|
|
2252
2282
|
|
2253
2283
|
EOF_main
|
2254
2284
|
|
2255
|
-
|
2256
|
-
|
2285
|
+
assert_equal expected, strip(input, 'C')
|
2286
|
+
end
|
2257
2287
|
|
2258
|
-
|
2288
|
+
def test_real_sample_5
|
2259
2289
|
|
2260
|
-
|
2290
|
+
input = <<-EOF_main
|
2261
2291
|
/*****************************************************************************
|
2262
2292
|
/* Start of crcmodel.c
|
2263
2293
|
/*****************************************************************************
|
@@ -2303,7 +2333,7 @@ LOCAL ulong reflect (ulong v, int b)
|
|
2303
2333
|
/* Returns the value v with the bottom b [0,32] bits reflected. */
|
2304
2334
|
/* Example: reflect(0x3e23L,3) == 0x3e26 */
|
2305
2335
|
EOF_main
|
2306
|
-
|
2336
|
+
expected = <<-EOF_main
|
2307
2337
|
|
2308
2338
|
|
2309
2339
|
|
@@ -2349,14 +2379,14 @@ LOCAL ulong reflect (ulong v, int b)
|
|
2349
2379
|
|
2350
2380
|
|
2351
2381
|
EOF_main
|
2352
|
-
|
2382
|
+
actual = strip(input, 'C')
|
2353
2383
|
|
2354
|
-
|
2355
|
-
|
2384
|
+
assert_equal expected, actual
|
2385
|
+
end
|
2356
2386
|
|
2357
|
-
|
2387
|
+
def _test_real_sample_6
|
2358
2388
|
|
2359
|
-
|
2389
|
+
input = <<-EOF_main
|
2360
2390
|
|
2361
2391
|
|
2362
2392
|
|
@@ -2445,7 +2475,7 @@ namespace {
|
|
2445
2475
|
default:
|
2446
2476
|
// Check for control characters and invalid utf-8
|
2447
2477
|
EOF_main
|
2448
|
-
x1 = <<-EOF_main
|
2478
|
+
x1 = <<-EOF_main
|
2449
2479
|
// Escape control characters in standard ascii
|
2450
2480
|
// see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0
|
2451
2481
|
if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) {
|
@@ -2646,7 +2676,7 @@ x1 = <<-EOF_main
|
|
2646
2676
|
}
|
2647
2677
|
EOF_main
|
2648
2678
|
|
2649
|
-
|
2679
|
+
expected = <<-EOF_main
|
2650
2680
|
|
2651
2681
|
|
2652
2682
|
|
@@ -2735,7 +2765,7 @@ namespace {
|
|
2735
2765
|
default:
|
2736
2766
|
|
2737
2767
|
EOF_main
|
2738
|
-
x1 = <<-EOF_main
|
2768
|
+
x1 = <<-EOF_main
|
2739
2769
|
|
2740
2770
|
|
2741
2771
|
|
@@ -2937,14 +2967,14 @@ x1 = <<-EOF_main
|
|
2937
2967
|
}
|
2938
2968
|
EOF_main
|
2939
2969
|
|
2940
|
-
|
2970
|
+
actual = strip(input, 'C')
|
2941
2971
|
|
2942
|
-
|
2943
|
-
|
2972
|
+
assert_equal expected, actual
|
2973
|
+
end
|
2944
2974
|
|
2945
|
-
|
2975
|
+
def test_real_sample_7
|
2946
2976
|
|
2947
|
-
|
2977
|
+
input = <<-EOF_main
|
2948
2978
|
#if defined(RECLS_CPP_NO_METHOD_PROPERTY_SUPPORT)
|
2949
2979
|
/* Do not define RECLS_CPP_METHOD_PROPERTY_SUPPORT */
|
2950
2980
|
#else /* ? RECLS_CPP_???_METHOD_PROPERTY_SUPPORT */
|
@@ -2966,7 +2996,7 @@ EOF_main
|
|
2966
2996
|
#endif /* RECLS_CPP_???_METHOD_PROPERTY_SUPPORT */
|
2967
2997
|
|
2968
2998
|
EOF_main
|
2969
|
-
|
2999
|
+
expected = <<-EOF_main
|
2970
3000
|
#if defined(RECLS_CPP_NO_METHOD_PROPERTY_SUPPORT)
|
2971
3001
|
|
2972
3002
|
#else
|
@@ -2989,14 +3019,14 @@ EOF_main
|
|
2989
3019
|
|
2990
3020
|
EOF_main
|
2991
3021
|
|
2992
|
-
|
3022
|
+
actual = strip(input, 'C')
|
2993
3023
|
|
2994
|
-
|
2995
|
-
|
3024
|
+
assert_equal expected, actual
|
3025
|
+
end
|
2996
3026
|
|
2997
|
-
|
3027
|
+
def test_real_sample_8
|
2998
3028
|
|
2999
|
-
|
3029
|
+
input = <<-EOF_main
|
3000
3030
|
/*****************************************************************************
|
3001
3031
|
/* Start of crcmodel.c
|
3002
3032
|
/*****************************************************************************
|
@@ -3141,7 +3171,7 @@ ulong cm_tab (p_cm_t p_cm, int index)
|
|
3141
3171
|
/* End of crcmodel.c */
|
3142
3172
|
/******************************************************************************/
|
3143
3173
|
EOF_main
|
3144
|
-
|
3174
|
+
expected = <<-EOF_main
|
3145
3175
|
|
3146
3176
|
|
3147
3177
|
|
@@ -3287,14 +3317,14 @@ ulong cm_tab (p_cm_t p_cm, int index)
|
|
3287
3317
|
|
3288
3318
|
EOF_main
|
3289
3319
|
|
3290
|
-
|
3320
|
+
actual = strip(input, 'C')
|
3291
3321
|
|
3292
|
-
|
3293
|
-
|
3322
|
+
assert_equal expected, actual
|
3323
|
+
end
|
3294
3324
|
|
3295
|
-
|
3325
|
+
def test_real_sample_9
|
3296
3326
|
|
3297
|
-
|
3327
|
+
input = <<-EOF_main
|
3298
3328
|
/*
|
3299
3329
|
* This source file is part of the bstring string library. This code was
|
3300
3330
|
* written by Paul Hsieh in 2002-2010, and is covered by either the 3-clause
|
@@ -3436,7 +3466,7 @@ int ret = 0;
|
|
3436
3466
|
}
|
3437
3467
|
|
3438
3468
|
EOF_main
|
3439
|
-
|
3469
|
+
expected = <<-EOF_main
|
3440
3470
|
|
3441
3471
|
|
3442
3472
|
|
@@ -3579,14 +3609,14 @@ int ret = 0;
|
|
3579
3609
|
|
3580
3610
|
EOF_main
|
3581
3611
|
|
3582
|
-
|
3612
|
+
actual = strip(input, 'C')
|
3583
3613
|
|
3584
|
-
|
3585
|
-
|
3614
|
+
assert_equal expected, actual
|
3615
|
+
end
|
3586
3616
|
|
3587
|
-
|
3617
|
+
def test_real_sample_10
|
3588
3618
|
|
3589
|
-
|
3619
|
+
input = <<-EOF_main
|
3590
3620
|
// Scintilla source code edit control
|
3591
3621
|
/** @file CharacterSet.h
|
3592
3622
|
** Encapsulates a set of characters. Used to test if a character is within a set.
|
@@ -3647,7 +3677,7 @@ public:
|
|
3647
3677
|
};
|
3648
3678
|
EOF_main
|
3649
3679
|
|
3650
|
-
|
3680
|
+
expected = <<-EOF_main
|
3651
3681
|
|
3652
3682
|
|
3653
3683
|
|
@@ -3708,10 +3738,10 @@ public:
|
|
3708
3738
|
};
|
3709
3739
|
EOF_main
|
3710
3740
|
|
3711
|
-
|
3741
|
+
actual = strip(input, 'C')
|
3712
3742
|
|
3713
|
-
|
3714
|
-
|
3743
|
+
assert_equal expected, actual
|
3744
|
+
end
|
3715
3745
|
end
|
3716
3746
|
|
3717
3747
|
# ############################## end of file ############################# #
|