rltk 2.2.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +12 -12
  3. data/README.md +458 -285
  4. data/Rakefile +99 -92
  5. data/lib/rltk/ast.rb +221 -126
  6. data/lib/rltk/cfg.rb +218 -239
  7. data/lib/rltk/cg/basic_block.rb +1 -1
  8. data/lib/rltk/cg/bindings.rb +9 -26
  9. data/lib/rltk/cg/builder.rb +40 -8
  10. data/lib/rltk/cg/context.rb +1 -1
  11. data/lib/rltk/cg/contractor.rb +51 -0
  12. data/lib/rltk/cg/execution_engine.rb +45 -8
  13. data/lib/rltk/cg/function.rb +12 -2
  14. data/lib/rltk/cg/generated_bindings.rb +2541 -575
  15. data/lib/rltk/cg/generic_value.rb +2 -2
  16. data/lib/rltk/cg/instruction.rb +104 -83
  17. data/lib/rltk/cg/llvm.rb +44 -3
  18. data/lib/rltk/cg/memory_buffer.rb +22 -5
  19. data/lib/rltk/cg/module.rb +85 -36
  20. data/lib/rltk/cg/old_generated_bindings.rb +6152 -0
  21. data/lib/rltk/cg/pass_manager.rb +87 -43
  22. data/lib/rltk/cg/support.rb +2 -4
  23. data/lib/rltk/cg/target.rb +158 -28
  24. data/lib/rltk/cg/triple.rb +8 -8
  25. data/lib/rltk/cg/type.rb +69 -25
  26. data/lib/rltk/cg/value.rb +107 -66
  27. data/lib/rltk/cg.rb +16 -17
  28. data/lib/rltk/lexer.rb +21 -11
  29. data/lib/rltk/lexers/calculator.rb +1 -1
  30. data/lib/rltk/lexers/ebnf.rb +8 -7
  31. data/lib/rltk/parser.rb +300 -247
  32. data/lib/rltk/parsers/infix_calc.rb +1 -1
  33. data/lib/rltk/parsers/postfix_calc.rb +2 -2
  34. data/lib/rltk/parsers/prefix_calc.rb +2 -2
  35. data/lib/rltk/token.rb +1 -2
  36. data/lib/rltk/version.rb +3 -3
  37. data/lib/rltk.rb +6 -6
  38. data/test/cg/tc_basic_block.rb +83 -0
  39. data/test/cg/tc_control_flow.rb +191 -0
  40. data/test/cg/tc_function.rb +54 -0
  41. data/test/cg/tc_generic_value.rb +33 -0
  42. data/test/cg/tc_instruction.rb +256 -0
  43. data/test/cg/tc_llvm.rb +25 -0
  44. data/test/cg/tc_math.rb +88 -0
  45. data/test/cg/tc_module.rb +89 -0
  46. data/test/cg/tc_transforms.rb +68 -0
  47. data/test/cg/tc_type.rb +69 -0
  48. data/test/cg/tc_value.rb +151 -0
  49. data/test/cg/ts_cg.rb +23 -0
  50. data/test/tc_ast.rb +105 -8
  51. data/test/tc_cfg.rb +63 -48
  52. data/test/tc_lexer.rb +84 -96
  53. data/test/tc_parser.rb +224 -52
  54. data/test/tc_token.rb +6 -6
  55. data/test/ts_rltk.rb +12 -15
  56. metadata +149 -75
  57. data/lib/rltk/cg/generated_extended_bindings.rb +0 -287
  58. data/lib/rltk/util/abstract_class.rb +0 -25
  59. data/lib/rltk/util/monkeys.rb +0 -129
data/test/tc_parser.rb CHANGED
@@ -8,9 +8,11 @@
8
8
  ############
9
9
 
10
10
  # Standard Library
11
- require 'test/unit'
12
11
  require 'tmpdir'
13
12
 
13
+ # Gems
14
+ require 'minitest/autorun'
15
+
14
16
  # Ruby Language Toolkit
15
17
  require 'rltk/lexer'
16
18
  require 'rltk/parser'
@@ -23,7 +25,7 @@ require 'rltk/parsers/postfix_calc'
23
25
  # Classes and Modules #
24
26
  #######################
25
27
 
26
- class ParserTester < Test::Unit::TestCase
28
+ class ParserTester < Minitest::Test
27
29
  class ABLexer < RLTK::Lexer
28
30
  rule(/a/) { [:A, 1] }
29
31
  rule(/b/) { [:B, 2] }
@@ -39,6 +41,10 @@ class ParserTester < Test::Unit::TestCase
39
41
  rule(/\s/)
40
42
  end
41
43
 
44
+ class UnderscoreLexer < RLTK::Lexer
45
+ rule(/\w/) { |t| [:A_TOKEN, t] }
46
+ end
47
+
42
48
  class APlusBParser < RLTK::Parser
43
49
  production(:a, 'A+ B') { |a, _| a.length }
44
50
 
@@ -71,7 +77,7 @@ class ParserTester < Test::Unit::TestCase
71
77
  end
72
78
 
73
79
  class ArrayCalc < RLTK::Parser
74
- array_args
80
+ dat :array
75
81
 
76
82
  production(:e) do
77
83
  clause('NUM') { |v| v[0] }
@@ -85,16 +91,56 @@ class ParserTester < Test::Unit::TestCase
85
91
  finalize
86
92
  end
87
93
 
94
+ # This grammar is purposefully ambiguous. This should not be equivalent
95
+ # to the grammar produced with `e -> A B? B?`, due to greedy Kleene
96
+ # operators.
97
+ class AmbiguousParseStackParser < RLTK::Parser
98
+ production(:s, 'e*') { |e| e }
99
+
100
+ production(:e, 'A b_question b_question') { |a, b0, b1| [a, b0, b1] }
101
+
102
+ production(:b_question) do
103
+ clause('') { | | nil }
104
+ clause('B') { |b| b }
105
+ end
106
+
107
+ finalize
108
+ end
109
+
88
110
  class EmptyListParser0 < RLTK::Parser
89
- empty_list('list', :A, :COMMA)
111
+ list('list', :A, :COMMA)
90
112
 
91
113
  finalize
92
114
  end
93
115
 
94
116
  class EmptyListParser1 < RLTK::Parser
95
- array_args
117
+ dat :array
118
+
119
+ list('list', ['A', 'B', 'C D'], :COMMA)
120
+
121
+ finalize
122
+ end
123
+
124
+ class GreedTestParser0 < RLTK::Parser
125
+ production(:e, 'A? A') { |a0, a1| [a0, a1] }
96
126
 
97
- empty_list('list', ['A', 'B', 'C D'], :COMMA)
127
+ finalize
128
+ end
129
+
130
+ class GreedTestParser1 < RLTK::Parser
131
+ production(:e, 'A? A?') { |a0, a1| [a0, a1] }
132
+
133
+ finalize
134
+ end
135
+
136
+ class GreedTestParser2 < RLTK::Parser
137
+ production(:e, 'A* A') { |a0, a1| [a0, a1] }
138
+
139
+ finalize
140
+ end
141
+
142
+ class GreedTestParser3 < RLTK::Parser
143
+ production(:e, 'A+ A') { |a0, a1| [a0, a1] }
98
144
 
99
145
  finalize
100
146
  end
@@ -108,7 +154,7 @@ class ParserTester < Test::Unit::TestCase
108
154
  class NonEmptyListParser1 < RLTK::Parser
109
155
  nonempty_list('list', [:A, :B], :COMMA)
110
156
 
111
- finalize
157
+ finalize explain: 'nelp1.tbl'
112
158
  end
113
159
 
114
160
  class NonEmptyListParser2 < RLTK::Parser
@@ -123,6 +169,18 @@ class ParserTester < Test::Unit::TestCase
123
169
  finalize
124
170
  end
125
171
 
172
+ class NonEmptyListParser4 < RLTK::Parser
173
+ nonempty_list('list', :A)
174
+
175
+ finalize
176
+ end
177
+
178
+ class NonEmptyListParser5 < RLTK::Parser
179
+ nonempty_list('list', :A, 'B C?')
180
+
181
+ finalize
182
+ end
183
+
126
184
  class DummyError1 < StandardError; end
127
185
  class DummyError2 < StandardError; end
128
186
 
@@ -166,7 +224,13 @@ class ParserTester < Test::Unit::TestCase
166
224
 
167
225
  finalize
168
226
  end
169
-
227
+
228
+ class UnderscoreParser < RLTK::Parser
229
+ production(:s, 'A_TOKEN+') { |o| o }
230
+
231
+ finalize
232
+ end
233
+
170
234
  class RotatingCalc < RLTK::Parser
171
235
  production(:e) do
172
236
  clause('NUM') {|n| n}
@@ -195,11 +259,24 @@ class ParserTester < Test::Unit::TestCase
195
259
  finalize
196
260
  end
197
261
 
262
+ class SelectionParser < RLTK::Parser
263
+ production(:s, 'A+ .B+') { |bs| bs.inject &:+ }
264
+
265
+ finalize
266
+ end
267
+
198
268
  def test_ambiguous_grammar
199
269
  actual = AmbiguousParser.parse(RLTK::Lexers::Calculator.lex('1 + 2 * 3'), {:accept => :all})
200
270
  assert_equal([7, 9], actual.sort)
201
271
  end
202
272
 
273
+ # This test is to ensure that objects placed on the output stack are
274
+ # cloned when we split the parse stack. This was posted as Issue #17 on
275
+ # Github.
276
+ def test_ambiguous_parse_stack
277
+ assert_equal(1, AmbiguousParseStackParser.parse(ABLexer.lex('ab')).length)
278
+ end
279
+
203
280
  def test_array_args
204
281
  actual = ArrayCalc.parse(RLTK::Lexers::Calculator.lex('+ 1 2'))
205
282
  assert_equal(3, actual)
@@ -216,7 +293,8 @@ class ParserTester < Test::Unit::TestCase
216
293
  # APlusBParser #
217
294
  ################
218
295
 
219
- assert_raise(RLTK::NotInLanguage) { APlusBParser.parse(ABLexer.lex('b')) }
296
+ assert_raises(RLTK::NotInLanguage) { APlusBParser.parse(ABLexer.lex('b')) }
297
+
220
298
  assert_equal(1, APlusBParser.parse(ABLexer.lex('ab')))
221
299
  assert_equal(2, APlusBParser.parse(ABLexer.lex('aab')))
222
300
  assert_equal(3, APlusBParser.parse(ABLexer.lex('aaab')))
@@ -226,9 +304,9 @@ class ParserTester < Test::Unit::TestCase
226
304
  # AQuestionBParser #
227
305
  ####################
228
306
 
229
- assert_raise(RLTK::NotInLanguage) { AQuestionBParser.parse(ABLexer.lex('aab')) }
307
+ assert_raises(RLTK::NotInLanguage) { AQuestionBParser.parse(ABLexer.lex('aab')) }
230
308
  assert_nil(AQuestionBParser.parse(ABLexer.lex('b')))
231
- assert_not_nil(AQuestionBParser.parse(ABLexer.lex('ab')))
309
+ refute_nil(AQuestionBParser.parse(ABLexer.lex('ab')))
232
310
 
233
311
  ################
234
312
  # AStarBParser #
@@ -246,16 +324,75 @@ class ParserTester < Test::Unit::TestCase
246
324
  # EmptyListParser0 #
247
325
  ####################
248
326
 
249
- expected = []
250
- actual = EmptyListParser0.parse(AlphaLexer.lex(''))
327
+ expected = []
328
+ actual = EmptyListParser0.parse(AlphaLexer.lex(''))
251
329
  assert_equal(expected, actual)
252
330
 
253
331
  ####################
254
332
  # EmptyListParser1 #
255
333
  ####################
256
334
 
257
- expected = ['a', 'b', ['c', 'd']]
258
- actual = EmptyListParser1.parse(AlphaLexer.lex('a, b, c d'))
335
+ expected = ['a', 'b', ['c', 'd']]
336
+ actual = EmptyListParser1.parse(AlphaLexer.lex('a, b, c d'))
337
+ assert_equal(expected, actual)
338
+ end
339
+
340
+ def test_greed
341
+
342
+ ####################
343
+ # GreedTestParser0 #
344
+ ####################
345
+
346
+ expected = [nil, 'a']
347
+ actual = GreedTestParser0.parse(AlphaLexer.lex('a'))
348
+ assert_equal(expected, actual)
349
+
350
+ expected = ['a', 'a']
351
+ actual = GreedTestParser0.parse(AlphaLexer.lex('a a'))
352
+ assert_equal(expected, actual)
353
+
354
+ ####################
355
+ # GreedTestParser1 #
356
+ ####################
357
+
358
+ expected = [nil, nil]
359
+ actual = GreedTestParser1.parse(AlphaLexer.lex(''))
360
+ assert_equal(expected, actual)
361
+
362
+ # expected = ['a', nil]
363
+ # actual = GreedTestParser1.parse(AlphaLexer.lex('a'))
364
+ # assert_equal(expected, actual)
365
+
366
+ expected = ['a', 'a']
367
+ actual = GreedTestParser1.parse(AlphaLexer.lex('a a'))
368
+ assert_equal(expected, actual)
369
+
370
+ ####################
371
+ # GreedTestParser2 #
372
+ ####################
373
+
374
+ expected = [[], 'a']
375
+ actual = GreedTestParser2.parse(AlphaLexer.lex('a'))
376
+ assert_equal(expected, actual)
377
+
378
+ expected = [['a'], 'a']
379
+ actual = GreedTestParser2.parse(AlphaLexer.lex('a a'))
380
+ assert_equal(expected, actual)
381
+
382
+ expected = [['a', 'a'], 'a']
383
+ actual = GreedTestParser2.parse(AlphaLexer.lex('a a a'))
384
+ assert_equal(expected, actual)
385
+
386
+ ####################
387
+ # GreedTestParser3 #
388
+ ####################
389
+
390
+ expected = [['a'], 'a']
391
+ actual = GreedTestParser3.parse(AlphaLexer.lex('a a'))
392
+ assert_equal(expected, actual)
393
+
394
+ expected = [['a', 'a'], 'a']
395
+ actual = GreedTestParser3.parse(AlphaLexer.lex('a a a'))
259
396
  assert_equal(expected, actual)
260
397
  end
261
398
 
@@ -287,7 +424,7 @@ class ParserTester < Test::Unit::TestCase
287
424
  test_string += "third line;\n"
288
425
  test_string += "fourth line\n"
289
426
 
290
- assert_raise(RLTK::HandledError) { ErrorLine.parse(ELLexer.lex(test_string)) }
427
+ assert_raises(RLTK::HandledError) { ErrorLine.parse(ELLexer.lex(test_string)) }
291
428
 
292
429
  begin
293
430
  ErrorLine.parse(ELLexer.lex(test_string))
@@ -328,11 +465,11 @@ class ParserTester < Test::Unit::TestCase
328
465
  actual = RLTK::Parsers::InfixCalc.parse(RLTK::Lexers::Calculator.lex('(1 + 2) * 3'))
329
466
  assert_equal(9, actual)
330
467
 
331
- assert_raise(RLTK::NotInLanguage) { RLTK::Parsers::InfixCalc.parse(RLTK::Lexers::Calculator.lex('1 2 + 3 *')) }
468
+ assert_raises(RLTK::NotInLanguage) { RLTK::Parsers::InfixCalc.parse(RLTK::Lexers::Calculator.lex('1 2 + 3 *')) }
332
469
  end
333
470
 
334
471
  def test_input
335
- assert_raise(RLTK::BadToken) { RLTK::Parsers::InfixCalc.parse(RLTK::Lexers::EBNF.lex('A B C')) }
472
+ assert_raises(RLTK::BadToken) { RLTK::Parsers::InfixCalc.parse(RLTK::Lexers::EBNF.lex('A B C')) }
336
473
  end
337
474
 
338
475
  def test_nonempty_list
@@ -340,72 +477,91 @@ class ParserTester < Test::Unit::TestCase
340
477
  # NonEmptyListParser0 #
341
478
  #######################
342
479
 
343
- expected = ['a']
344
- actual = NonEmptyListParser0.parse(AlphaLexer.lex('a'))
480
+ expected = ['a']
481
+ actual = NonEmptyListParser0.parse(AlphaLexer.lex('a'))
345
482
  assert_equal(expected, actual)
346
483
 
347
- expected = ['a', 'a']
348
- actual = NonEmptyListParser0.parse(AlphaLexer.lex('a, a'))
484
+ expected = ['a', 'a']
485
+ actual = NonEmptyListParser0.parse(AlphaLexer.lex('a, a'))
349
486
  assert_equal(expected, actual)
350
487
 
351
- assert_raise(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex('')) }
352
- assert_raise(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex(',')) }
353
- assert_raise(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex('aa')) }
354
- assert_raise(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex('a,')) }
355
- assert_raise(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex(',a')) }
488
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex('')) }
489
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex(',')) }
490
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex('aa')) }
491
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex('a,')) }
492
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser0.parse(AlphaLexer.lex(',a')) }
356
493
 
357
494
  #######################
358
495
  # NonEmptyListParser1 #
359
496
  #######################
360
497
 
361
- expected = ['a']
362
- actual = NonEmptyListParser1.parse(AlphaLexer.lex('a'))
498
+ expected = ['a']
499
+ actual = NonEmptyListParser1.parse(AlphaLexer.lex('a'))
363
500
  assert_equal(expected, actual)
364
501
 
365
- expected = ['b']
366
- actual = NonEmptyListParser1.parse(AlphaLexer.lex('b'))
502
+ expected = ['b']
503
+ actual = NonEmptyListParser1.parse(AlphaLexer.lex('b'))
367
504
  assert_equal(expected, actual)
368
505
 
369
- expected = ['a', 'b', 'a', 'b']
370
- actual = NonEmptyListParser1.parse(AlphaLexer.lex('a, b, a, b'))
506
+ expected = ['a', 'b', 'a', 'b']
507
+ actual = NonEmptyListParser1.parse(AlphaLexer.lex('a, b, a, b'))
371
508
  assert_equal(expected, actual)
372
509
 
373
- assert_raise(RLTK::NotInLanguage) { NonEmptyListParser1.parse(AlphaLexer.lex('a b')) }
510
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser1.parse(AlphaLexer.lex('a b')) }
511
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser1.parse(AlphaLexer.lex('a, ')) }
374
512
 
375
513
  #######################
376
514
  # NonEmptyListParser2 #
377
515
  #######################
378
516
 
379
- expected = ['a']
380
- actual = NonEmptyListParser2.parse(AlphaLexer.lex('a'))
517
+ expected = ['a']
518
+ actual = NonEmptyListParser2.parse(AlphaLexer.lex('a'))
381
519
  assert_equal(expected, actual)
382
520
 
383
- expected = ['b']
384
- actual = NonEmptyListParser2.parse(AlphaLexer.lex('b'))
521
+ expected = ['b']
522
+ actual = NonEmptyListParser2.parse(AlphaLexer.lex('b'))
385
523
  assert_equal(expected, actual)
386
524
 
387
- expected = [['c', 'd']]
388
- actual = NonEmptyListParser2.parse(AlphaLexer.lex('c d'))
525
+ expected = [['c', 'd']]
526
+ actual = NonEmptyListParser2.parse(AlphaLexer.lex('c d'))
389
527
  assert_equal(expected, actual)
390
528
 
391
- expected = [['c', 'd'], ['c', 'd']]
392
- actual = NonEmptyListParser2.parse(AlphaLexer.lex('c d, c d'))
529
+ expected = [['c', 'd'], ['c', 'd']]
530
+ actual = NonEmptyListParser2.parse(AlphaLexer.lex('c d, c d'))
393
531
  assert_equal(expected, actual)
394
532
 
395
- expected = ['a', 'b', ['c', 'd']]
396
- actual = NonEmptyListParser2.parse(AlphaLexer.lex('a, b, c d'))
533
+ expected = ['a', 'b', ['c', 'd']]
534
+ actual = NonEmptyListParser2.parse(AlphaLexer.lex('a, b, c d'))
397
535
  assert_equal(expected, actual)
398
536
 
399
- assert_raise(RLTK::NotInLanguage) { NonEmptyListParser2.parse(AlphaLexer.lex('c')) }
400
- assert_raise(RLTK::NotInLanguage) { NonEmptyListParser2.parse(AlphaLexer.lex('d')) }
537
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser2.parse(AlphaLexer.lex('c')) }
538
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser2.parse(AlphaLexer.lex('d')) }
401
539
 
402
540
  #######################
403
541
  # NonEmptyListParser3 #
404
542
  #######################
405
543
 
406
- expected = [['a'], ['a', 'a'], ['a', 'a', 'a']]
407
- actual = NonEmptyListParser3.parse(AlphaLexer.lex('a, aa, aaa'))
544
+ expected = [['a'], ['a', 'a'], ['a', 'a', 'a']]
545
+ actual = NonEmptyListParser3.parse(AlphaLexer.lex('a, aa, aaa'))
408
546
  assert_equal(expected, actual)
547
+
548
+ #######################
549
+ # NonEmptyListParser4 #
550
+ #######################
551
+
552
+ expected = ['a', 'a', 'a']
553
+ actual = NonEmptyListParser4.parse(AlphaLexer.lex('a a a'))
554
+ assert_equal(expected, actual)
555
+
556
+ #######################
557
+ # NonEmptyListParser5 #
558
+ #######################
559
+
560
+ expected = ['a', 'a', 'a']
561
+ actual = NonEmptyListParser5.parse(AlphaLexer.lex('a b a b c a'))
562
+ assert_equal(expected, actual)
563
+
564
+ assert_raises(RLTK::NotInLanguage) { NonEmptyListParser5.parse(AlphaLexer.lex('a b b a')) }
409
565
  end
410
566
 
411
567
  def test_postfix_calc
@@ -418,7 +574,7 @@ class ParserTester < Test::Unit::TestCase
418
574
  actual = RLTK::Parsers::PostfixCalc.parse(RLTK::Lexers::Calculator.lex('1 2 + 3 *'))
419
575
  assert_equal(9, actual)
420
576
 
421
- assert_raise(RLTK::NotInLanguage) { RLTK::Parsers::InfixCalc.parse(RLTK::Lexers::Calculator.lex('* + 1 2 3')) }
577
+ assert_raises(RLTK::NotInLanguage) { RLTK::Parsers::InfixCalc.parse(RLTK::Lexers::Calculator.lex('* + 1 2 3')) }
422
578
  end
423
579
 
424
580
  def test_prefix_calc
@@ -431,16 +587,32 @@ class ParserTester < Test::Unit::TestCase
431
587
  actual = RLTK::Parsers::PrefixCalc.parse(RLTK::Lexers::Calculator.lex('* + 1 2 3'))
432
588
  assert_equal(9, actual)
433
589
 
434
- assert_raise(RLTK::NotInLanguage) { RLTK::Parsers::PrefixCalc.parse(RLTK::Lexers::Calculator.lex('1 + 2 * 3')) }
590
+ assert_raises(RLTK::NotInLanguage) { RLTK::Parsers::PrefixCalc.parse(RLTK::Lexers::Calculator.lex('1 + 2 * 3')) }
591
+ end
592
+
593
+ def test_selection_parser
594
+ actual = SelectionParser.parse(ABLexer.lex('aaabbb'))
595
+ expected = 6
596
+
597
+ assert_equal(expected, actual)
598
+ end
599
+
600
+ def test_underscore_tokens
601
+ actual = UnderscoreParser.parse(UnderscoreLexer.lex('abc')).join
602
+ expected = 'abc'
603
+
604
+ assert_equal(expected, actual)
435
605
  end
436
606
 
437
607
  def test_use
438
608
  tmpfile = File.join(Dir.tmpdir, 'usetest')
439
609
 
610
+ FileUtils.rm(tmpfile) if File.exist?(tmpfile)
611
+
440
612
  parser0 = Class.new(RLTK::Parser) do
441
613
  production(:a, 'A+') { |a| a.length }
442
614
 
443
- finalize :use => tmpfile
615
+ finalize use: tmpfile
444
616
  end
445
617
 
446
618
  result0 = parser0.parse(ABLexer.lex('a'))
@@ -450,7 +622,7 @@ class ParserTester < Test::Unit::TestCase
450
622
  parser1 = Class.new(RLTK::Parser) do
451
623
  production(:a, 'A+') { |a| a.length }
452
624
 
453
- finalize :use => tmpfile
625
+ finalize use: tmpfile
454
626
  end
455
627
 
456
628
  result1 = parser1.parse(ABLexer.lex('a'))
data/test/tc_token.rb CHANGED
@@ -7,8 +7,8 @@
7
7
  # Requires #
8
8
  ############
9
9
 
10
- # Standard Library
11
- require 'test/unit'
10
+ # Gems
11
+ require 'minitest/autorun'
12
12
 
13
13
  # Ruby Language Toolkit
14
14
  require 'rltk/token'
@@ -17,7 +17,7 @@ require 'rltk/token'
17
17
  # Classes and Modules #
18
18
  #######################
19
19
 
20
- class TokenTester < Test::Unit::TestCase
20
+ class TokenTester < Minitest::Test
21
21
  def test_equal
22
22
  t0 = RLTK::Token.new(:FOO, 0)
23
23
  t1 = RLTK::Token.new(:FOO, 0)
@@ -27,8 +27,8 @@ class TokenTester < Test::Unit::TestCase
27
27
 
28
28
  assert_equal(t0, t1)
29
29
 
30
- assert_not_equal(t0, t2)
31
- assert_not_equal(t0, t3)
32
- assert_not_equal(t0, t4)
30
+ refute_equal(t0, t2)
31
+ refute_equal(t0, t3)
32
+ refute_equal(t0, t4)
33
33
  end
34
34
  end
data/test/ts_rltk.rb CHANGED
@@ -8,21 +8,17 @@
8
8
  # Requires #
9
9
  ############
10
10
 
11
- if RUBY_VERSION[0..2] == '1.9'
12
- begin
13
- require 'simplecov'
14
- SimpleCov.start do
15
- add_filter 'tc_*'
16
- add_filter 'generated*'
17
- end
18
-
19
- rescue LoadError
20
- puts 'SimpleCov not installed. Continuing without it.'
11
+ # Filigree
12
+ require 'filigree/request_file'
13
+
14
+ request_file('simplecov', 'SimpleCov is not installed.') do
15
+ SimpleCov.start do
16
+ add_filter 'tc_*'
17
+ add_filter 'generated*'
21
18
  end
22
19
  end
23
20
 
24
- # Rubygems
25
- require 'rubygems'
21
+ # Gems
26
22
  require 'ffi'
27
23
 
28
24
  # Ruby Language Toolkit
@@ -35,9 +31,8 @@ require 'tc_cfg'
35
31
  require 'tc_lexer'
36
32
  require 'tc_parser'
37
33
 
38
- require 'util/ts_util'
39
-
40
34
  begin
35
+ # Check to make sure the target LLVM library is present.
41
36
  class Tester
42
37
  extend FFI::Library
43
38
 
@@ -46,5 +41,7 @@ begin
46
41
 
47
42
  # The test suite for the LLVM bindings
48
43
  require 'cg/ts_cg'
49
- rescue
44
+
45
+ rescue LoadError
46
+ puts "Unable to test LLVM bindings. Library LLVM-#{RLTK::LLVM_TARGET_VERSION} not found."
50
47
  end