citrus 1.8.0 → 2.0.0
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.
- data/README +53 -46
- data/benchmark/after.dat +192 -0
- data/benchmark/before.dat +192 -0
- data/benchmark/master.dat +192 -0
- data/doc/background.markdown +9 -10
- data/doc/example.markdown +24 -15
- data/doc/syntax.markdown +20 -21
- data/lib/citrus.rb +208 -178
- data/lib/citrus/debug.rb +34 -4
- data/test/file_test.rb +12 -12
- data/test/helper.rb +27 -5
- data/test/match_test.rb +18 -34
- data/test/parse_error_test.rb +56 -0
- data/test/terminal_test.rb +56 -0
- metadata +10 -7
- data/test/expression_test.rb +0 -29
- data/test/fixed_width_test.rb +0 -37
data/test/expression_test.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
class ExpressionTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_terminal?
|
6
|
-
rule = Expression.new
|
7
|
-
assert(rule.terminal?)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_match
|
11
|
-
rule = Expression.new(/\d+/)
|
12
|
-
match = rule.match(input('123 456'))
|
13
|
-
assert(match)
|
14
|
-
assert_equal('123', match)
|
15
|
-
assert_equal(3, match.length)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_match_failure
|
19
|
-
rule = Expression.new(/\d+/)
|
20
|
-
match = rule.match(input(' 456'))
|
21
|
-
assert_equal(nil, match)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_to_s
|
25
|
-
rule = Expression.new(/\d+/)
|
26
|
-
assert_equal('/\\d+/', rule.to_s)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
data/test/fixed_width_test.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
class FixedWidthTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_terminal?
|
6
|
-
rule = FixedWidth.new
|
7
|
-
assert(rule.terminal?)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_match
|
11
|
-
rule = FixedWidth.new('abc')
|
12
|
-
match = rule.match(input('abc'))
|
13
|
-
assert(match)
|
14
|
-
assert_equal('abc', match)
|
15
|
-
assert_equal(3, match.length)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_match_short
|
19
|
-
rule = FixedWidth.new('abc')
|
20
|
-
match = rule.match(input('ab'))
|
21
|
-
assert_equal(nil, match)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_match_long
|
25
|
-
rule = FixedWidth.new('abc')
|
26
|
-
match = rule.match(input('abcd'))
|
27
|
-
assert(match)
|
28
|
-
assert_equal('abc', match)
|
29
|
-
assert_equal(3, match.length)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_to_s
|
33
|
-
rule = FixedWidth.new('abc')
|
34
|
-
assert_equal('"abc"', rule.to_s)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|