livetext 0.9.26 → 0.9.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/livetext/funcall.rb +13 -94
  3. data/lib/livetext/lineparser.rb +165 -31
  4. data/lib/livetext/parser/string.rb +14 -5
  5. data/lib/livetext/skeleton.rb +0 -4
  6. data/lib/livetext/standard.rb +2 -2
  7. data/lib/livetext/userapi.rb +0 -1
  8. data/lib/livetext/version.rb +1 -1
  9. data/lib/livetext.rb +0 -1
  10. data/test/snapshots/basic_formatting/actual-output.txt +8 -8
  11. data/test/snapshots/basic_formatting/out-sdiff.txt +8 -8
  12. data/test/snapshots/functions/actual-error.txt +19 -0
  13. data/test/snapshots/functions/actual-output.txt +0 -0
  14. data/test/snapshots/functions/err-sdiff.txt +20 -0
  15. data/test/snapshots/more_complex_vars/actual-error.txt +0 -0
  16. data/test/snapshots/more_complex_vars/actual-output.txt +4 -0
  17. data/test/snapshots/more_complex_vars/err-sdiff.txt +1 -0
  18. data/test/snapshots/more_complex_vars/out-sdiff.txt +5 -0
  19. data/test/snapshots/more_functions/actual-error.txt +19 -0
  20. data/test/snapshots/more_functions/actual-output.txt +0 -37
  21. data/test/snapshots/more_functions/err-sdiff.txt +19 -0
  22. data/test/snapshots/raw_lines/actual-error.txt +22 -0
  23. data/test/snapshots/raw_lines/actual-output.txt +0 -0
  24. data/test/snapshots/raw_lines/err-sdiff.txt +23 -0
  25. data/test/snapshots/simple_vars/actual-output.txt +2 -2
  26. data/test/snapshots/simple_vars/out-sdiff.txt +2 -2
  27. data/test/snapshots/var_into_func/actual-error.txt +19 -0
  28. data/test/snapshots/var_into_func/actual-output.txt +0 -16
  29. data/test/snapshots/var_into_func/err-sdiff.txt +19 -0
  30. data/test/unit/all.rb +0 -1
  31. data/test/unit/lineparser.rb +62 -353
  32. data/test/unit/new_lineparser.rb +359 -0
  33. data/test/unit/tokenizer.rb +2 -1
  34. metadata +13 -6
  35. data/lib/livetext/formatline.rb +0 -408
  36. data/test/snapshots/more_functions/out-sdiff.txt +0 -38
  37. data/test/testlines.rb +0 -37
  38. data/test/unit/formatline.rb +0 -638
@@ -1,638 +0,0 @@
1
- require 'minitest/autorun'
2
-
3
- require_relative '../../lib/livetext'
4
-
5
- class TestingLivetext < MiniTest::Test
6
-
7
- FormatLine = Livetext::FormatLine
8
-
9
- def invoke_test(msg, src, exp)
10
- actual = FormatLine.parse!(src)
11
- if exp[0] == "/"
12
- exp = Regexp.compile(exp[1..-2]) # skip slashes
13
- $testme = false
14
- assert_match(exp, actual, msg)
15
- else
16
- $testme = false
17
- assert_equal(exp, actual, msg)
18
- end
19
- end
20
-
21
- # Some (most) methods were generated via the code
22
- # seen in the comment at the bottom of this file...
23
-
24
- def test_simple_string
25
- parse = FormatLine.new("only testing")
26
- tokens = parse.tokenize
27
- assert_equal tokens, [[:str, "only testing"]], "Tokens were: #{tokens.inspect}"
28
- expected = "only testing"
29
- result = parse.evaluate
30
- assert_equal expected, result
31
- end
32
-
33
- def test_variable_interpolation
34
- parse = FormatLine.new("File is $File and user is $User")
35
- tokens = parse.tokenize
36
- expected_tokens = [[:str, "File is "],
37
- [:var, "File"],
38
- [:str, " and user is "],
39
- [:var, "User"]]
40
- assert_equal expected_tokens, tokens
41
- result = parse.evaluate
42
- expected = "File is [File is undefined] and user is Hal" # FIXME
43
- assert_equal expected, result
44
- end
45
-
46
- def test_func_expansion
47
- parse = FormatLine.new("myfunc() results in $$myfunc apparently.")
48
- tokens = parse.tokenize
49
- expected_tokens = [[:str, "myfunc() results in "],
50
- [:func, "myfunc"],
51
- [:str, " apparently."]]
52
- assert_equal expected_tokens, tokens
53
- result = parse.evaluate
54
- expected = "myfunc() results in [Error evaluating $$myfunc()] apparently."
55
- assert_equal expected, result
56
- end
57
-
58
- # These tests follow this form:
59
- #
60
- # def test_func_SUFFIX
61
- # str = "WHATEVER"
62
- # parse = FormatLine.new(str)
63
- # tokens_expected = [[], [], ...]
64
- # tokens = parse.tokenize
65
- # assert_equal tokens_expected, tokens
66
- # result = parse.evaluate
67
- # regex_expected = /Today is ....-..-../
68
- # assert_match regex_expected, result, "Found unexpected: #{result.inspect}"
69
- # end
70
-
71
- def xtest_func_2
72
- str = "Today is $$date"
73
- parse = FormatLine.new(str)
74
- tokens_expected = [[:str, "Today is "], [:func, "date"]]
75
- tokens = parse.tokenize
76
- assert_equal tokens_expected, tokens, "Tokens were: #{tokens.inspect}"
77
- result = parse.evaluate
78
- regex_expected = /Today is ....-..-../
79
- assert_match regex_expected, result, "Found unexpected: #{result.inspect}"
80
- end
81
-
82
- def xtest_var_before_comma
83
- str = "User name is $User, and all is well"
84
- parse = FormatLine.new(str)
85
- tokens_expected = [[:str, "User name is "], [:var, "User"], [:str, ", and all is well"]]
86
- tokens = parse.tokenize
87
- assert_equal tokens_expected, tokens, "Tokens were: #{tokens.inspect}"
88
- result = parse.evaluate
89
- regex_expected = /User name is .*, /
90
- assert_match regex_expected, result, "Found unexpected: #{result.inspect}"
91
- end
92
-
93
- def xtest_var_at_EOS
94
- str = "File name is $File"
95
- parse = FormatLine.new(str)
96
- tokens_expected = [[:str, "File name is "], [:var, "File"]]
97
- tokens = parse.tokenize
98
- assert_equal tokens_expected, tokens
99
- result = parse.evaluate
100
- string_expected = "File name is [File is undefined]"
101
- assert_equal string_expected, result, "Found unexpected: #{result.inspect}"
102
- end
103
-
104
- def xtest_var_starts_string
105
- str = "$File is my file name"
106
- parse = FormatLine.new(str)
107
- tokens_expected = [[:var, "File"], [:str, " is my file name"]]
108
- tokens = parse.tokenize
109
- assert_equal tokens_expected, tokens
110
- result = parse.evaluate
111
- string_expected = "[File is undefined] is my file name"
112
- assert_equal string_expected, result, "Found unexpected: #{result.inspect}"
113
- end
114
-
115
- # Next one is/will be a problem...
116
- # I permit periods *inside* variable names
117
-
118
- def xtest_var_before_period
119
- str = "This is $File\\." # FIXME escaped for now...
120
- parse = FormatLine.new(str)
121
- tokens_expected = [[:str, "This is "], [:var, "File"], [:str, "."]]
122
- tokens = parse.tokenize
123
- assert_equal tokens_expected, tokens
124
- result = parse.evaluate
125
- string_expected = "This is [File is undefined]."
126
- assert_equal string_expected, result, "Found unexpected: #{result.inspect}"
127
- end
128
-
129
- def xtest_func_needing_parameter_colon_eos # colon, param, EOS
130
- str = "Square root of 225 is $$isqrt:225"
131
- parse = FormatLine.new(str)
132
- tokens_expected = [[:str, "Square root of 225 is "], [:func, "isqrt"], [:colon, "225"]]
133
- tokens = parse.tokenize
134
- assert_equal tokens_expected, tokens
135
- result = parse.evaluate
136
- string_expected = "Square root of 225 is 15"
137
- assert_equal string_expected, result, "Found unexpected: #{result.inspect}"
138
- end
139
-
140
- def xtest_func_needing_parameter_colon # colon, param, more chars
141
- str = "Answer is $$isqrt:225 today"
142
- parse = FormatLine.new(str)
143
- tokens_expected = [[:str, "Answer is "],
144
- [:func, "isqrt"],
145
- [:colon, "225"],
146
- [:str, " today"]]
147
- tokens = parse.tokenize
148
- assert_equal tokens_expected, tokens
149
- result = parse.evaluate
150
- string_expected = "Answer is 15 today"
151
- assert_equal string_expected, result, "Found unexpected: #{result.inspect}"
152
- end
153
-
154
- # isqrt: Not real tests??
155
-
156
- def xtest_isqrt_empty_colon_param
157
- str = "Calculate $$isqrt:"
158
- parse = FormatLine.new(str)
159
- tokens_expected = [[:str, "Calculate "],
160
- [:func, "isqrt"] # , [:colon, ""]
161
- ]
162
- # If param is null, we don't get [:colon, value]!
163
- # ^ FIXME function should be more like: [:func, name, param]
164
- tokens = parse.tokenize
165
- assert_equal tokens_expected, tokens
166
- result = parse.evaluate
167
- string_expected = "Calculate [Error evaluating $$isqrt(NO PARAM)]"
168
- assert_equal string_expected, result, "Found unexpected: #{result.inspect}"
169
- end
170
-
171
- def xtest_isqrt_empty_bracket_param
172
- str = "Calculate $$isqrt[]"
173
- parse = FormatLine.new(str)
174
- tokens_expected = [[:str, "Calculate "],
175
- [:func, "isqrt"] # , [:colon, ""]
176
- ]
177
- # If param is null, we don't get [:colon, value]!
178
- # ^ FIXME function should be more like: [:func, name, param]
179
- tokens = parse.tokenize
180
- assert_equal tokens_expected, tokens
181
- result = parse.evaluate
182
- string_expected = "Calculate [Error evaluating $$isqrt(NO PARAM)]"
183
- assert_equal string_expected, result, "Found unexpected: #{result.inspect}"
184
- end
185
-
186
- def xtest_isqrt_malformed_number
187
- str = "Calculate $$isqrt[3a5]"
188
- parse = FormatLine.new(str)
189
- tokens_expected = [[:str, "Calculate "],
190
- [:func, "isqrt"],
191
- [:brackets, "3a5"]
192
- ]
193
- # ^ FIXME function should be more like: [:func, name, param]
194
- tokens = parse.tokenize
195
- assert_equal tokens_expected, tokens
196
- result = parse.evaluate
197
- string_expected = "Calculate [Error evaluating $$isqrt(3a5)]"
198
- assert_equal string_expected, result, "Found unexpected: #{result.inspect}"
199
- end
200
-
201
- # ...end of this group
202
-
203
- def xtest_func_with_colon
204
- parse = FormatLine.new("Calling $$myfunc:foo here.")
205
- tokens = parse.tokenize
206
- assert_equal tokens, [[:str, "Calling "],
207
- [:func, "myfunc"],
208
- [:colon, "foo"],
209
- [:str, " here."]
210
- ]
211
- result = parse.evaluate
212
- expected = "Calling [Error evaluating $$myfunc(foo)] here."
213
- assert_equal expected, result
214
- end
215
-
216
- def xtest_func_with_brackets
217
- parse = FormatLine.new("Calling $$myfunc2[foo bar] here.")
218
- tokens = parse.tokenize
219
- assert_kind_of Array, tokens
220
- assert_equal 4, tokens.size
221
- expected_tokens = [[:str, "Calling "],
222
- [:func, "myfunc2"],
223
- [:brackets, "foo bar"],
224
- [:str, " here."]]
225
- assert_equal expected_tokens, tokens
226
- result = parse.evaluate
227
- expected = "Calling [Error evaluating $$myfunc2(foo bar)] here."
228
- assert_equal expected, result
229
- end
230
-
231
- def xtest_parse_formatting
232
- msg, src, exp = <<~STUFF.split("\n")
233
- Check simple formatting
234
- This is *bold and _italics ...
235
- This is <b>bold</b> and <i>italics</i> ...
236
- STUFF
237
- invoke_test(msg, src, exp)
238
- end
239
-
240
- def xtest_formatting_01 # Check output of $$date
241
- msg, src, exp = <<~STUFF.split("\n")
242
- Check output of $$date
243
- Today is $$date, I guess
244
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
245
- STUFF
246
- invoke_test(msg, src, exp)
247
- end
248
-
249
- def xtest_formatting_02 # Check output of $$date
250
- msg, src, exp = <<~STUFF.split("\n")
251
- Check output of $$date
252
- Today is $$date, I guess
253
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
254
- STUFF
255
- invoke_test(msg, src, exp)
256
- end
257
-
258
- def xtest_formatting_03 # Check output of $$date
259
- msg, src, exp = <<~STUFF.split("\n")
260
- Check output of $$date
261
- Today is $$date, I guess
262
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
263
- STUFF
264
- invoke_test(msg, src, exp)
265
- end
266
-
267
- def xtest_formatting_04 # Check output of $$date
268
- msg, src, exp = <<~STUFF.split("\n")
269
- Check output of $$date
270
- Today is $$date, I guess
271
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
272
- STUFF
273
- invoke_test(msg, src, exp)
274
- end
275
-
276
- def xtest_formatting_05 # 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
- invoke_test(msg, src, exp)
283
- end
284
-
285
- def xtest_formatting_06 # Check output of $$date
286
- msg, src, exp = <<~STUFF.split("\n")
287
- Check output of $$date
288
- Today is $$date, I guess
289
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
290
- STUFF
291
- invoke_test(msg, src, exp)
292
-
293
- actual = FormatLine.parse!(src)
294
- if exp[0] == "/"
295
- exp = Regexp.compile(exp[1..-2]) # skip slashes
296
- assert_match(exp, actual, msg)
297
- else
298
- assert_equal(exp, actual, msg)
299
- end
300
- end
301
-
302
- def xtest_formatting_07 # Check output of $$date
303
- msg, src, exp = <<~STUFF.split("\n")
304
- Check output of $$date
305
- Today is $$date, I guess
306
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
307
- STUFF
308
- invoke_test(msg, src, exp)
309
-
310
- actual = FormatLine.parse!(src)
311
- if exp[0] == "/"
312
- exp = Regexp.compile(exp[1..-2]) # skip slashes
313
- assert_match(exp, actual, msg)
314
- else
315
- assert_equal(exp, actual, msg)
316
- end
317
- end
318
-
319
- def xtest_formatting_08 # Check output of $$date
320
- msg, src, exp = <<~STUFF.split("\n")
321
- Check output of $$date
322
- Today is $$date, I guess
323
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
324
- STUFF
325
- invoke_test(msg, src, exp)
326
- end
327
-
328
- def xtest_formatting_09 # Check output of $$date
329
- msg, src, exp = <<~STUFF.split("\n")
330
- Check output of $$date
331
- Today is $$date, I guess
332
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
333
- STUFF
334
- invoke_test(msg, src, exp)
335
- end
336
-
337
- def xtest_formatting_10 # Check output of $$date
338
- msg, src, exp = <<~STUFF.split("\n")
339
- Check output of $$date
340
- Today is $$date, I guess
341
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
342
- STUFF
343
- invoke_test(msg, src, exp)
344
- end
345
-
346
- def xtest_formatting_11 # Check output of $$date
347
- msg, src, exp = <<~STUFF.split("\n")
348
- Check output of $$date
349
- Today is $$date, I guess
350
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
351
- STUFF
352
- invoke_test(msg, src, exp)
353
- end
354
-
355
- def xtest_formatting_12 # Check output of $$date
356
- msg, src, exp = <<~STUFF.split("\n")
357
- Check output of $$date
358
- Today is $$date, I guess
359
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
360
- STUFF
361
- invoke_test(msg, src, exp)
362
- end
363
-
364
- def xtest_formatting_13 # Check output of $$date
365
- msg, src, exp = <<~STUFF.split("\n")
366
- Check output of $$date
367
- Today is $$date, I guess
368
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
369
- STUFF
370
- invoke_test(msg, src, exp)
371
- end
372
-
373
- def xtest_formatting_14 # Check output of $$date
374
- msg, src, exp = <<~STUFF.split("\n")
375
- Check output of $$date
376
- Today is $$date, I guess
377
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
378
- STUFF
379
- invoke_test(msg, src, exp)
380
- end
381
-
382
- def xtest_formatting_15 # Check output of $$date
383
- msg, src, exp = <<~STUFF.split("\n")
384
- Check output of $$date
385
- Today is $$date, I guess
386
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
387
- STUFF
388
- invoke_test(msg, src, exp)
389
- end
390
-
391
- def xtest_formatting_16 # Check output of $$date
392
- msg, src, exp = <<~STUFF.split("\n")
393
- Check output of $$date
394
- Today is $$date, I guess
395
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
396
- STUFF
397
- invoke_test(msg, src, exp)
398
- end
399
-
400
- def xtest_formatting_17 # Check output of $$date
401
- msg, src, exp = <<~STUFF.split("\n")
402
- Check output of $$date
403
- Today is $$date, I guess
404
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
405
- STUFF
406
- invoke_test(msg, src, exp)
407
- end
408
-
409
- def xtest_formatting_18 # Check output of $$date
410
- msg, src, exp = <<~STUFF.split("\n")
411
- Check output of $$date
412
- Today is $$date, I guess
413
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
414
- STUFF
415
- invoke_test(msg, src, exp)
416
- end
417
-
418
- def xtest_formatting_19 # Check output of $$date
419
- msg, src, exp = <<~STUFF.split("\n")
420
- Check output of $$date
421
- Today is $$date, I guess
422
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
423
- STUFF
424
- invoke_test(msg, src, exp)
425
- end
426
-
427
- def xtest_formatting_20 # Check output of $$date
428
- msg, src, exp = <<~STUFF.split("\n")
429
- Check output of $$date
430
- Today is $$date, I guess
431
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
432
- STUFF
433
- invoke_test(msg, src, exp)
434
- end
435
-
436
- def xtest_formatting_21 # Check output of $$date
437
- msg, src, exp = <<~STUFF.split("\n")
438
- Check output of $$date
439
- Today is $$date, I guess
440
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
441
- STUFF
442
- invoke_test(msg, src, exp)
443
- end
444
-
445
- def xtest_formatting_22 # Check output of $$date
446
- msg, src, exp = <<~STUFF.split("\n")
447
- Check output of $$date
448
- Today is $$date, I guess
449
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
450
- STUFF
451
- invoke_test(msg, src, exp)
452
- end
453
-
454
- def xtest_formatting_23 # Check output of $$date
455
- msg, src, exp = <<~STUFF.split("\n")
456
- Check output of $$date
457
- Today is $$date, I guess
458
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
459
- STUFF
460
- invoke_test(msg, src, exp)
461
- end
462
-
463
- def xtest_formatting_24 # 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
- invoke_test(msg, src, exp)
470
- end
471
-
472
- def xtest_formatting_25 # Check output of $$date
473
- msg, src, exp = <<~STUFF.split("\n")
474
- Check output of $$date
475
- Today is $$date, I guess
476
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
477
- STUFF
478
- invoke_test(msg, src, exp)
479
- end
480
-
481
- def xtest_formatting_26 # Check output of $$date
482
- msg, src, exp = <<~STUFF.split("\n")
483
- Check output of $$date
484
- Today is $$date, I guess
485
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
486
- STUFF
487
- invoke_test(msg, src, exp)
488
- end
489
-
490
- def xtest_formatting_27 # Check output of $$date
491
- msg, src, exp = <<~STUFF.split("\n")
492
- Check output of $$date
493
- Today is $$date, I guess
494
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
495
- STUFF
496
- invoke_test(msg, src, exp)
497
- end
498
-
499
- def xtest_formatting_28 # Check output of $$date
500
- msg, src, exp = <<~STUFF.split("\n")
501
- Check output of $$date
502
- Today is $$date, I guess
503
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
504
- STUFF
505
- invoke_test(msg, src, exp)
506
- end
507
-
508
- def xtest_formatting_29 # Check output of $$date
509
- msg, src, exp = <<~STUFF.split("\n")
510
- Check output of $$date
511
- Today is $$date, I guess
512
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
513
- STUFF
514
- invoke_test(msg, src, exp)
515
- end
516
-
517
- def xtest_formatting_30 # Check output of $$date
518
- msg, src, exp = <<~STUFF.split("\n")
519
- Check output of $$date
520
- Today is $$date, I guess
521
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
522
- STUFF
523
- invoke_test(msg, src, exp)
524
- end
525
-
526
- def xtest_formatting_31 # Check output of $$date
527
- msg, src, exp = <<~STUFF.split("\n")
528
- Check output of $$date
529
- Today is $$date, I guess
530
- /Today is \\d\\d\\d\\d-\\d\\d-\\d\\d, I guess/
531
- STUFF
532
- invoke_test(msg, src, exp)
533
- end
534
-
535
- def xtest_formatting_32 # Check "real" dollar signs
536
- msg, src, exp = <<~STUFF.split("\n")
537
- Check "real" dollar signs
538
- You paid $75 for that item.
539
- You paid $75 for that item.
540
- STUFF
541
- invoke_test(msg, src, exp)
542
- end
543
-
544
- def xtest_formatting_33 # Check dollar-space
545
- msg, src, exp = <<~STUFF.split("\n")
546
- Check dollar-space
547
- He paid $ 76 for it...
548
- He paid $ 76 for it...
549
- STUFF
550
- invoke_test(msg, src, exp)
551
- end
552
-
553
- def test_formatting_34 # Check escaped dollar signs
554
- $testme = true
555
- msg, src, exp = <<~STUFF.split("\n")
556
- Check escaped dollar signs
557
- I paid \\$78 for it, though.
558
- I paid $78 for it, though.
559
- STUFF
560
- invoke_test(msg, src, exp)
561
- $testme = false
562
- end
563
-
564
- def xtest_formatting_35 # Check ignored function param (bug or feature?)
565
- $testme = true
566
- msg, src, exp = <<~STUFF.split("\n")
567
- Check ignored function param (bug or feature?)
568
- Today is $$date:foobar, apparently.
569
- /Today is \\d\\d\\d\\d.\\d\\d.\\d\\d apparently./
570
- STUFF
571
- invoke_test(msg, src, exp)
572
- $testme = false
573
- end
574
-
575
- def xtest_formatting_36 # Check ignored function bracket param (bug or feature?)
576
- msg, src, exp = <<~STUFF.split("\n")
577
- Check ignored function bracket param (bug or feature?)
578
- Today is $$date[a useless parameter], apparently.
579
- /Today is \\d\\\d\\d\\d.\\d\\d.\\d\\d, apparently./
580
- STUFF
581
- invoke_test(msg, src, exp)
582
- end
583
-
584
- end
585
-
586
- # Test generation logic:
587
-
588
- =begin
589
- TestLines = []
590
-
591
- items = []
592
- formatting_tests = File.open("test/snapshots/formatting-tests.txt")
593
- loop do
594
- 4.times { items << formatting_tests.gets.chomp }
595
- # Blank line terminates each "stanza"
596
- raise "Oops? #{items.inspect}" unless items.last.empty?
597
- TestLines << items
598
- break if formatting_tests.eof?
599
- end
600
-
601
- STDERR.puts <<~RUBY
602
- require 'minitest/autorun'
603
-
604
- require_relative '../lib/livetext'
605
-
606
- # Just another testing class. Chill.
607
-
608
- class TestingLivetext < MiniTest::Test
609
- RUBY
610
-
611
- TestLines.each.with_index do |item, num|
612
- msg, src, exp, blank = *item
613
- # generate tests...
614
- name = "test_formatting_#{'%02d' % (num + 1)}"
615
- method_source = <<~RUBY
616
- def #{name} # #{msg}
617
- msg, src, exp = <<~STUFF.split("\\n")
618
- #{msg}
619
- #{src}
620
- #{exp}
621
- STUFF
622
-
623
- actual = FormatLine.parse!(src)
624
- # FIXME could simplify assert logic?
625
- if exp[0] == "/"
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
- RUBY
634
- STDERR.puts method_source
635
- end
636
- STDERR.puts "\nend"
637
- end
638
- =end