Skip to content
Newer
Older
100644 47 lines (37 sloc) 1.04 KB
0d0f2eb @mjackson Added the ButPredicate to be used with the tilde.
authored
1 require File.expand_path('../helper', __FILE__)
2
3 class ButPredicateTest < Test::Unit::TestCase
4 def test_terminal?
5 rule = ButPredicate.new
6 assert_equal(false, rule.terminal?)
7 end
8
456adbe @mjackson Introduced more lightweight parsing model
authored
9 def test_exec
10 rule = ButPredicate.new('abc')
0d0f2eb @mjackson Added the ButPredicate to be used with the tilde.
authored
11
456adbe @mjackson Introduced more lightweight parsing model
authored
12 events = rule.exec(Input.new('def'))
e924053 @mjackson Eliminate Rule id's
authored
13 assert_equal([rule, CLOSE, 3], events)
0d0f2eb @mjackson Added the ButPredicate to be used with the tilde.
authored
14
456adbe @mjackson Introduced more lightweight parsing model
authored
15 events = rule.exec(Input.new('defabc'))
e924053 @mjackson Eliminate Rule id's
authored
16 assert_equal([rule, CLOSE, 3], events)
456adbe @mjackson Introduced more lightweight parsing model
authored
17 end
940862b @mjackson Added some tests for ButPredicate.
authored
18
456adbe @mjackson Introduced more lightweight parsing model
authored
19 def test_exec_miss
20 rule = ButPredicate.new('abc')
21 events = rule.exec(Input.new('abc'))
22 assert_equal([], events)
23 end
940862b @mjackson Added some tests for ButPredicate.
authored
24
456adbe @mjackson Introduced more lightweight parsing model
authored
25 def test_consumption
4ff6f59 @mjackson Fixed predicate consumption bug
authored
26 rule = ButPredicate.new(Sequence.new(['a', 'b', 'c']))
456adbe @mjackson Introduced more lightweight parsing model
authored
27
28 input = Input.new('def')
29 events = rule.exec(input)
30 assert_equal(3, input.pos)
31
32 input = Input.new('defabc')
33 events = rule.exec(input)
34 assert_equal(3, input.pos)
0d0f2eb @mjackson Added the ButPredicate to be used with the tilde.
authored
35 end
36
37 def test_to_s
38 rule = ButPredicate.new('a')
39 assert_equal('~"a"', rule.to_s)
40 end
7f32be2 @mjackson Eliminate Label, Predicate, and List classes.
authored
41
42 def test_to_s_with_label
43 rule = ButPredicate.new('a')
44 rule.label = 'a_label'
45 assert_equal('a_label:~"a"', rule.to_s)
46 end
0d0f2eb @mjackson Added the ButPredicate to be used with the tilde.
authored
47 end
Something went wrong with that request. Please try again.