livetext 0.9.14 → 0.9.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cmdargs.rb +93 -0
  3. data/lib/formatline.rb +56 -83
  4. data/lib/helpers.rb +142 -4
  5. data/lib/livetext.rb +11 -141
  6. data/lib/parser/file.rb +8 -0
  7. data/lib/parser/mixin.rb +28 -15
  8. data/lib/parser/set.rb +35 -26
  9. data/lib/parser/string.rb +19 -4
  10. data/lib/processor.rb +1 -4
  11. data/lib/standard.rb +56 -96
  12. data/plugin/bookish.rb +26 -22
  13. data/plugin/calibre.rb +1 -1
  14. data/plugin/livemagick.rb +10 -10
  15. data/plugin/markdown.rb +13 -11
  16. data/plugin/pyggish.rb +94 -84
  17. data/plugin/tutorial.rb +10 -5
  18. data/test/all.rb +0 -1
  19. data/test/snapshots/OMIT.txt +7 -8
  20. data/test/snapshots/clusion.txt +35 -0
  21. data/test/snapshots/error_inc_line_num/actual-error.txt +14 -0
  22. data/test/snapshots/error_inc_line_num/actual-output.txt +7 -0
  23. data/test/snapshots/error_inc_line_num/match-error.txt +1 -1
  24. data/test/snapshots/error_inc_line_num/out-sdiff.txt +14 -0
  25. data/test/snapshots/error_invalid_name/actual-error.txt +10 -0
  26. data/test/snapshots/error_invalid_name/actual-output.txt +0 -0
  27. data/test/snapshots/error_invalid_name/match-error.txt +1 -1
  28. data/test/snapshots/error_invalid_name/out-sdiff.txt +6 -0
  29. data/test/snapshots/error_line_num/match-error.txt +1 -1
  30. data/test/snapshots/error_mismatched_end/match-error.txt +1 -1
  31. data/test/snapshots/error_missing_end/actual-error.txt +10 -0
  32. data/test/snapshots/error_missing_end/actual-output.txt +0 -0
  33. data/test/snapshots/error_missing_end/match-error.txt +1 -1
  34. data/test/snapshots/error_missing_end/out-sdiff.txt +6 -0
  35. data/test/snapshots/error_no_such_copy/actual-error.txt +10 -0
  36. data/test/snapshots/error_no_such_copy/actual-output.txt +0 -0
  37. data/test/snapshots/error_no_such_copy/match-error.txt +1 -1
  38. data/test/snapshots/error_no_such_copy/out-sdiff.txt +5 -0
  39. data/test/snapshots/error_no_such_copy/source.lt3 +0 -1
  40. data/test/snapshots/error_no_such_inc/actual-error.txt +10 -0
  41. data/test/snapshots/error_no_such_inc/actual-output.txt +0 -0
  42. data/test/snapshots/error_no_such_inc/match-error.txt +1 -1
  43. data/test/snapshots/error_no_such_inc/out-sdiff.txt +6 -0
  44. data/test/snapshots/error_no_such_mixin/actual-error.txt +37 -0
  45. data/test/snapshots/error_no_such_mixin/actual-output.txt +0 -0
  46. data/test/snapshots/error_no_such_mixin/out-sdiff.txt +6 -0
  47. data/test/snapshots/simple_import/actual-error.txt +8 -0
  48. data/test/snapshots/simple_import/actual-output.txt +3 -0
  49. data/test/snapshots/simple_import/err-sdiff.txt +9 -0
  50. data/test/snapshots/simple_import/expected-error.txt +0 -0
  51. data/test/snapshots/simple_import/expected-output.txt +7 -0
  52. data/test/snapshots/simple_import/out-sdiff.txt +9 -0
  53. data/test/snapshots/simple_import/simple_import.rb +5 -0
  54. data/test/snapshots/simple_import/source.lt3 +7 -0
  55. data/test/snapshots/simple_include/source.lt3 +0 -1
  56. data/test/snapshots.rb +3 -2
  57. data/test/unit/all.rb +1 -0
  58. data/test/unit/formatline.rb +650 -0
  59. data/test/unit/parser/importable.rb +1 -1
  60. data/test/unit/parser/mixin.rb +1 -1
  61. data/test/unit/parser/set.rb +19 -12
  62. data/test/unit/parser/string.rb +14 -14
  63. metadata +32 -5
  64. data/test/formatting-tests.rb +0 -35
  65. data/test/formatting.rb +0 -103
  66. data/test/snapshots/formatting-tests.txt +0 -124
@@ -0,0 +1,5 @@
1
+ module SimpleImport
2
+ def hello_world
3
+ _out "Hello, world."
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ Here I am
2
+ testing a simple import
3
+ .mixin simple_import
4
+
5
+ Now call a method:
6
+ .hello_world
7
+ That's all.
@@ -1,5 +1,4 @@
1
1
  Here I am
2
- .debug
3
2
  trying to
4
3
  include
5
4
  .include simplefile.inc
data/test/snapshots.rb CHANGED
@@ -53,7 +53,8 @@ class TestingLivetext < MiniTest::Test
53
53
  @match_out = File.exist?(MATCH_OUT)
54
54
  @match_err = File.exist?(MATCH_ERR)
55
55
  end
56
- bad_files = (@literal_out && @match_out) || (@literal_err && @match_err)
56
+ bad_files = (@literal_out && @match_out) || (@literal_err && @match_err) ||
57
+ (! @literal_out && ! @match_out)
57
58
  raise "Inconsistent structure for #@base" if bad_files
58
59
  end
59
60
 
@@ -116,8 +117,8 @@ class TestingLivetext < MiniTest::Test
116
117
  Dir.chdir(@base) do
117
118
  cmd = "../../../bin/livetext #{SOURCE} >#{ACTUAL_OUT} 2>#{ACTUAL_ERR}"
118
119
  system(cmd)
119
- check_stdout
120
120
  check_stderr
121
+ check_stdout
121
122
  cleanup
122
123
  end
123
124
  end
data/test/unit/all.rb CHANGED
@@ -1,3 +1,4 @@
1
1
 
2
2
  require_relative 'standard'
3
3
  require_relative 'parser' # nested
4
+ require_relative 'formatline'
@@ -0,0 +1,650 @@
1
+ require 'minitest/autorun'
2
+
3
+ require_relative '../../lib/livetext'
4
+
5
+ class TestingLivetext < MiniTest::Test
6
+
7
+ # Some (most) methods were generated via...
8
+
9
+ =begin
10
+ TestLines = []
11
+
12
+ items = []
13
+ formatting_tests = File.open("test/snapshots/formatting-tests.txt")
14
+ loop do
15
+ 4.times { items << formatting_tests.gets.chomp }
16
+ # Blank line terminates each "stanza"
17
+ raise "Oops? #{items.inspect}" unless items.last.empty?
18
+ TestLines << items
19
+ break if formatting_tests.eof?
20
+ end
21
+
22
+ STDERR.puts <<~RUBY
23
+ require 'minitest/autorun'
24
+
25
+ require_relative '../lib/livetext'
26
+
27
+ # Just another testing class. Chill.
28
+
29
+ class TestingLivetext < MiniTest::Test
30
+ RUBY
31
+
32
+ TestLines.each.with_index do |item, num|
33
+ msg, src, exp, blank = *item
34
+ # generate tests...
35
+ name = "test_formatting_#{'%02d' % (num + 1)}"
36
+ method_source = <<~RUBY
37
+ def #{name} # #{msg}
38
+ msg, src, exp = <<~STUFF.split("\\n")
39
+ #{msg}
40
+ #{src}
41
+ #{exp}
42
+ STUFF
43
+
44
+ actual = FormatLine.parse!(src)
45
+ # FIXME could simplify assert logic?
46
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
47
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
48
+ assert_match(exp, actual, msg)
49
+ else
50
+ assert_equal(exp, actual, msg)
51
+ end
52
+ end
53
+
54
+ RUBY
55
+ STDERR.puts method_source
56
+ end
57
+ STDERR.puts "\nend"
58
+ end
59
+ =end
60
+
61
+ def test_simple_string
62
+ parse = FormatLine.new("only testing")
63
+ tokens = parse.tokenize
64
+ assert_equal tokens, [[:str, "only testing"]]
65
+ expected = "only testing"
66
+ result = parse.evaluate
67
+ assert result == expected
68
+ end
69
+
70
+ def test_variable_interpolation
71
+ parse = FormatLine.new("File is $File and user is $User")
72
+ tokens = parse.tokenize
73
+ assert_equal tokens, [[:str, "File is "],
74
+ [:var, "File"],
75
+ [:str, " and user is "],
76
+ [:var, "User"]
77
+ ]
78
+ result = parse.evaluate
79
+ expected = "File is [File is undefined] and user is [User is undefined]"
80
+ assert result == expected
81
+ end
82
+
83
+ def test_func_expansion
84
+ parse = FormatLine.new("myfunc() results in $$myfunc apparently.")
85
+ tokens = parse.tokenize
86
+ assert_equal tokens, [[:str, "myfunc() results in "],
87
+ [:func, "myfunc"],
88
+ [:str, " apparently."]
89
+ ]
90
+ result = parse.evaluate
91
+ expected = "myfunc() results in [Error evaluating $$myfunc()] apparently."
92
+ assert result == expected
93
+ end
94
+
95
+ def test_func_with_colon
96
+ parse = FormatLine.new("Calling $$myfunc:foo here.")
97
+ tokens = parse.tokenize
98
+ assert_equal tokens, [[:str, "Calling "],
99
+ [:func, "myfunc"],
100
+ [:colon, "foo"],
101
+ [:str, " here."]
102
+ ]
103
+ result = parse.evaluate
104
+ expected = "Calling [Error evaluating $$myfunc(foo)] here."
105
+ assert result == expected
106
+ end
107
+
108
+ def test_func_with_brackets
109
+ parse = FormatLine.new("Calling $$myfunc2[foo bar] here.")
110
+ tokens = parse.tokenize
111
+ assert_kind_of Array, tokens
112
+ assert tokens.size == 4
113
+ assert_equal tokens, [[:str, "Calling "],
114
+ [:func, "myfunc2"],
115
+ [:brackets, "foo bar"],
116
+ [:str, " here."]
117
+ ]
118
+ result = parse.evaluate
119
+ expected = "Calling [Error evaluating $$myfunc2(foo bar)] here."
120
+ assert result == expected
121
+ end
122
+
123
+ def test_formatting_01 # Check output of $$date
124
+ msg, src, exp = <<~STUFF.split("\n")
125
+ Check output of $$date
126
+ Today is $$date, I guess
127
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
128
+ STUFF
129
+
130
+ actual = FormatLine.parse!(src)
131
+ # FIXME could simplify assert logic?
132
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
133
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
134
+ assert_match(exp, actual, msg)
135
+ else
136
+ assert_equal(exp, actual, msg)
137
+ end
138
+ end
139
+
140
+ def test_formatting_02 # Check output of $$date
141
+ msg, src, exp = <<~STUFF.split("\n")
142
+ Check output of $$date
143
+ Today is $$date, I guess
144
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
145
+ STUFF
146
+
147
+ actual = FormatLine.parse!(src)
148
+ # FIXME could simplify assert logic?
149
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
150
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
151
+ assert_match(exp, actual, msg)
152
+ else
153
+ assert_equal(exp, actual, msg)
154
+ end
155
+ end
156
+
157
+ def test_formatting_03 # Check output of $$date
158
+ msg, src, exp = <<~STUFF.split("\n")
159
+ Check output of $$date
160
+ Today is $$date, I guess
161
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
162
+ STUFF
163
+
164
+ actual = FormatLine.parse!(src)
165
+ # FIXME could simplify assert logic?
166
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
167
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
168
+ assert_match(exp, actual, msg)
169
+ else
170
+ assert_equal(exp, actual, msg)
171
+ end
172
+ end
173
+
174
+ def test_formatting_04 # Check output of $$date
175
+ msg, src, exp = <<~STUFF.split("\n")
176
+ Check output of $$date
177
+ Today is $$date, I guess
178
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
179
+ STUFF
180
+
181
+ actual = FormatLine.parse!(src)
182
+ # FIXME could simplify assert logic?
183
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
184
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
185
+ assert_match(exp, actual, msg)
186
+ else
187
+ assert_equal(exp, actual, msg)
188
+ end
189
+ end
190
+
191
+ def test_formatting_05 # Check output of $$date
192
+ msg, src, exp = <<~STUFF.split("\n")
193
+ Check output of $$date
194
+ Today is $$date, I guess
195
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
196
+ STUFF
197
+
198
+ actual = FormatLine.parse!(src)
199
+ # FIXME could simplify assert logic?
200
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
201
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
202
+ assert_match(exp, actual, msg)
203
+ else
204
+ assert_equal(exp, actual, msg)
205
+ end
206
+ end
207
+
208
+ def test_formatting_06 # Check output of $$date
209
+ msg, src, exp = <<~STUFF.split("\n")
210
+ Check output of $$date
211
+ Today is $$date, I guess
212
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
213
+ STUFF
214
+
215
+ actual = FormatLine.parse!(src)
216
+ # FIXME could simplify assert logic?
217
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
218
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
219
+ assert_match(exp, actual, msg)
220
+ else
221
+ assert_equal(exp, actual, msg)
222
+ end
223
+ end
224
+
225
+ def test_formatting_07 # Check output of $$date
226
+ msg, src, exp = <<~STUFF.split("\n")
227
+ Check output of $$date
228
+ Today is $$date, I guess
229
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
230
+ STUFF
231
+
232
+ actual = FormatLine.parse!(src)
233
+ # FIXME could simplify assert logic?
234
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
235
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
236
+ assert_match(exp, actual, msg)
237
+ else
238
+ assert_equal(exp, actual, msg)
239
+ end
240
+ end
241
+
242
+ def test_formatting_08 # Check output of $$date
243
+ msg, src, exp = <<~STUFF.split("\n")
244
+ Check output of $$date
245
+ Today is $$date, I guess
246
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
247
+ STUFF
248
+
249
+ actual = FormatLine.parse!(src)
250
+ # FIXME could simplify assert logic?
251
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
252
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
253
+ assert_match(exp, actual, msg)
254
+ else
255
+ assert_equal(exp, actual, msg)
256
+ end
257
+ end
258
+
259
+ def test_formatting_09 # Check output of $$date
260
+ msg, src, exp = <<~STUFF.split("\n")
261
+ Check output of $$date
262
+ Today is $$date, I guess
263
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
264
+ STUFF
265
+
266
+ actual = FormatLine.parse!(src)
267
+ # FIXME could simplify assert logic?
268
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
269
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
270
+ assert_match(exp, actual, msg)
271
+ else
272
+ assert_equal(exp, actual, msg)
273
+ end
274
+ end
275
+
276
+ def test_formatting_10 # Check output of $$date
277
+ msg, src, exp = <<~STUFF.split("\n")
278
+ Check output of $$date
279
+ Today is $$date, I guess
280
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
281
+ STUFF
282
+
283
+ actual = FormatLine.parse!(src)
284
+ # FIXME could simplify assert logic?
285
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
286
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
287
+ assert_match(exp, actual, msg)
288
+ else
289
+ assert_equal(exp, actual, msg)
290
+ end
291
+ end
292
+
293
+ def test_formatting_11 # Check output of $$date
294
+ msg, src, exp = <<~STUFF.split("\n")
295
+ Check output of $$date
296
+ Today is $$date, I guess
297
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
298
+ STUFF
299
+
300
+ actual = FormatLine.parse!(src)
301
+ # FIXME could simplify assert logic?
302
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
303
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
304
+ assert_match(exp, actual, msg)
305
+ else
306
+ assert_equal(exp, actual, msg)
307
+ end
308
+ end
309
+
310
+ def test_formatting_12 # Check output of $$date
311
+ msg, src, exp = <<~STUFF.split("\n")
312
+ Check output of $$date
313
+ Today is $$date, I guess
314
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
315
+ STUFF
316
+
317
+ actual = FormatLine.parse!(src)
318
+ # FIXME could simplify assert logic?
319
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
320
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
321
+ assert_match(exp, actual, msg)
322
+ else
323
+ assert_equal(exp, actual, msg)
324
+ end
325
+ end
326
+
327
+ def test_formatting_13 # Check output of $$date
328
+ msg, src, exp = <<~STUFF.split("\n")
329
+ Check output of $$date
330
+ Today is $$date, I guess
331
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
332
+ STUFF
333
+
334
+ actual = FormatLine.parse!(src)
335
+ # FIXME could simplify assert logic?
336
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
337
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
338
+ assert_match(exp, actual, msg)
339
+ else
340
+ assert_equal(exp, actual, msg)
341
+ end
342
+ end
343
+
344
+ def test_formatting_14 # Check output of $$date
345
+ msg, src, exp = <<~STUFF.split("\n")
346
+ Check output of $$date
347
+ Today is $$date, I guess
348
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
349
+ STUFF
350
+
351
+ actual = FormatLine.parse!(src)
352
+ # FIXME could simplify assert logic?
353
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
354
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
355
+ assert_match(exp, actual, msg)
356
+ else
357
+ assert_equal(exp, actual, msg)
358
+ end
359
+ end
360
+
361
+ def test_formatting_15 # Check output of $$date
362
+ msg, src, exp = <<~STUFF.split("\n")
363
+ Check output of $$date
364
+ Today is $$date, I guess
365
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
366
+ STUFF
367
+
368
+ actual = FormatLine.parse!(src)
369
+ # FIXME could simplify assert logic?
370
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
371
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
372
+ assert_match(exp, actual, msg)
373
+ else
374
+ assert_equal(exp, actual, msg)
375
+ end
376
+ end
377
+
378
+ def test_formatting_16 # Check output of $$date
379
+ msg, src, exp = <<~STUFF.split("\n")
380
+ Check output of $$date
381
+ Today is $$date, I guess
382
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
383
+ STUFF
384
+
385
+ actual = FormatLine.parse!(src)
386
+ # FIXME could simplify assert logic?
387
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
388
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
389
+ assert_match(exp, actual, msg)
390
+ else
391
+ assert_equal(exp, actual, msg)
392
+ end
393
+ end
394
+
395
+ def test_formatting_17 # Check output of $$date
396
+ msg, src, exp = <<~STUFF.split("\n")
397
+ Check output of $$date
398
+ Today is $$date, I guess
399
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
400
+ STUFF
401
+
402
+ actual = FormatLine.parse!(src)
403
+ # FIXME could simplify assert logic?
404
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
405
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
406
+ assert_match(exp, actual, msg)
407
+ else
408
+ assert_equal(exp, actual, msg)
409
+ end
410
+ end
411
+
412
+ def test_formatting_18 # Check output of $$date
413
+ msg, src, exp = <<~STUFF.split("\n")
414
+ Check output of $$date
415
+ Today is $$date, I guess
416
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
417
+ STUFF
418
+
419
+ actual = FormatLine.parse!(src)
420
+ # FIXME could simplify assert logic?
421
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
422
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
423
+ assert_match(exp, actual, msg)
424
+ else
425
+ assert_equal(exp, actual, msg)
426
+ end
427
+ end
428
+
429
+ def test_formatting_19 # Check output of $$date
430
+ msg, src, exp = <<~STUFF.split("\n")
431
+ Check output of $$date
432
+ Today is $$date, I guess
433
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
434
+ STUFF
435
+
436
+ actual = FormatLine.parse!(src)
437
+ # FIXME could simplify assert logic?
438
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
439
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
440
+ assert_match(exp, actual, msg)
441
+ else
442
+ assert_equal(exp, actual, msg)
443
+ end
444
+ end
445
+
446
+ def test_formatting_20 # Check output of $$date
447
+ msg, src, exp = <<~STUFF.split("\n")
448
+ Check output of $$date
449
+ Today is $$date, I guess
450
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
451
+ STUFF
452
+
453
+ actual = FormatLine.parse!(src)
454
+ # FIXME could simplify assert logic?
455
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
456
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
457
+ assert_match(exp, actual, msg)
458
+ else
459
+ assert_equal(exp, actual, msg)
460
+ end
461
+ end
462
+
463
+ def test_formatting_21 # Check output of $$date
464
+ msg, src, exp = <<~STUFF.split("\n")
465
+ Check output of $$date
466
+ Today is $$date, I guess
467
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
468
+ STUFF
469
+
470
+ actual = FormatLine.parse!(src)
471
+ # FIXME could simplify assert logic?
472
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
473
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
474
+ assert_match(exp, actual, msg)
475
+ else
476
+ assert_equal(exp, actual, msg)
477
+ end
478
+ end
479
+
480
+ def test_formatting_22 # Check output of $$date
481
+ msg, src, exp = <<~STUFF.split("\n")
482
+ Check output of $$date
483
+ Today is $$date, I guess
484
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
485
+ STUFF
486
+
487
+ actual = FormatLine.parse!(src)
488
+ # FIXME could simplify assert logic?
489
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
490
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
491
+ assert_match(exp, actual, msg)
492
+ else
493
+ assert_equal(exp, actual, msg)
494
+ end
495
+ end
496
+
497
+ def test_formatting_23 # Check output of $$date
498
+ msg, src, exp = <<~STUFF.split("\n")
499
+ Check output of $$date
500
+ Today is $$date, I guess
501
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
502
+ STUFF
503
+
504
+ actual = FormatLine.parse!(src)
505
+ # FIXME could simplify assert logic?
506
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
507
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
508
+ assert_match(exp, actual, msg)
509
+ else
510
+ assert_equal(exp, actual, msg)
511
+ end
512
+ end
513
+
514
+ def test_formatting_24 # Check output of $$date
515
+ msg, src, exp = <<~STUFF.split("\n")
516
+ Check output of $$date
517
+ Today is $$date, I guess
518
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
519
+ STUFF
520
+
521
+ actual = FormatLine.parse!(src)
522
+ # FIXME could simplify assert logic?
523
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
524
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
525
+ assert_match(exp, actual, msg)
526
+ else
527
+ assert_equal(exp, actual, msg)
528
+ end
529
+ end
530
+
531
+ def test_formatting_25 # Check output of $$date
532
+ msg, src, exp = <<~STUFF.split("\n")
533
+ Check output of $$date
534
+ Today is $$date, I guess
535
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
536
+ STUFF
537
+
538
+ actual = FormatLine.parse!(src)
539
+ # FIXME could simplify assert logic?
540
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
541
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
542
+ assert_match(exp, actual, msg)
543
+ else
544
+ assert_equal(exp, actual, msg)
545
+ end
546
+ end
547
+
548
+ def test_formatting_26 # Check output of $$date
549
+ msg, src, exp = <<~STUFF.split("\n")
550
+ Check output of $$date
551
+ Today is $$date, I guess
552
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
553
+ STUFF
554
+
555
+ actual = FormatLine.parse!(src)
556
+ # FIXME could simplify assert logic?
557
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
558
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
559
+ assert_match(exp, actual, msg)
560
+ else
561
+ assert_equal(exp, actual, msg)
562
+ end
563
+ end
564
+
565
+ def test_formatting_27 # Check output of $$date
566
+ msg, src, exp = <<~STUFF.split("\n")
567
+ Check output of $$date
568
+ Today is $$date, I guess
569
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
570
+ STUFF
571
+
572
+ actual = FormatLine.parse!(src)
573
+ # FIXME could simplify assert logic?
574
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
575
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
576
+ assert_match(exp, actual, msg)
577
+ else
578
+ assert_equal(exp, actual, msg)
579
+ end
580
+ end
581
+
582
+ def test_formatting_28 # Check output of $$date
583
+ msg, src, exp = <<~STUFF.split("\n")
584
+ Check output of $$date
585
+ Today is $$date, I guess
586
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
587
+ STUFF
588
+
589
+ actual = FormatLine.parse!(src)
590
+ # FIXME could simplify assert logic?
591
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
592
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
593
+ assert_match(exp, actual, msg)
594
+ else
595
+ assert_equal(exp, actual, msg)
596
+ end
597
+ end
598
+
599
+ def test_formatting_29 # Check output of $$date
600
+ msg, src, exp = <<~STUFF.split("\n")
601
+ Check output of $$date
602
+ Today is $$date, I guess
603
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
604
+ STUFF
605
+
606
+ actual = FormatLine.parse!(src)
607
+ # FIXME could simplify assert logic?
608
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
609
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
610
+ assert_match(exp, actual, msg)
611
+ else
612
+ assert_equal(exp, actual, msg)
613
+ end
614
+ end
615
+
616
+ def test_formatting_30 # Check output of $$date
617
+ msg, src, exp = <<~STUFF.split("\n")
618
+ Check output of $$date
619
+ Today is $$date, I guess
620
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
621
+ STUFF
622
+
623
+ actual = FormatLine.parse!(src)
624
+ # FIXME could simplify assert logic?
625
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
626
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
627
+ assert_match(exp, actual, msg)
628
+ else
629
+ assert_equal(exp, actual, msg)
630
+ end
631
+ end
632
+
633
+ def test_formatting_31 # Check output of $$date
634
+ msg, src, exp = <<~STUFF.split("\n")
635
+ Check output of $$date
636
+ Today is $$date, I guess
637
+ /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
638
+ STUFF
639
+
640
+ actual = FormatLine.parse!(src)
641
+ # FIXME could simplify assert logic?
642
+ if exp[0] == "/" # regex! FIXME doesn't honor %r[...]
643
+ exp = Regexp.compile(exp[1..-2]) # skip slashes
644
+ assert_match(exp, actual, msg)
645
+ else
646
+ assert_equal(exp, actual, msg)
647
+ end
648
+ end
649
+
650
+ end
@@ -3,7 +3,7 @@ require 'minitest/autorun'
3
3
 
4
4
  require_relative '../../../lib/parser/set'
5
5
 
6
- ParseSet = Livetext::ParseSet
6
+ # ParseSet = Livetext::ParseSet
7
7
 
8
8
  class TestParseSet < MiniTest::Test
9
9