regexp_parser 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +6 -0
  3. data/lib/regexp_parser/syntax/ruby/1.9.1.rb +1 -1
  4. data/lib/regexp_parser/syntax/tokens/escape.rb +2 -0
  5. data/lib/regexp_parser/version.rb +1 -1
  6. data/test/expression/test_base.rb +32 -34
  7. data/test/expression/test_clone.rb +49 -47
  8. data/test/expression/test_conditionals.rb +40 -40
  9. data/test/expression/test_free_space.rb +4 -2
  10. data/test/expression/test_set.rb +16 -16
  11. data/test/expression/test_strfregexp.rb +74 -74
  12. data/test/expression/test_subexpression.rb +2 -2
  13. data/test/expression/test_tests.rb +57 -57
  14. data/test/expression/test_to_h.rb +11 -6
  15. data/test/expression/test_to_s.rb +22 -15
  16. data/test/expression/test_traverse.rb +26 -29
  17. data/test/lexer/test_all.rb +9 -7
  18. data/test/lexer/test_conditionals.rb +35 -11
  19. data/test/lexer/test_keep.rb +6 -6
  20. data/test/lexer/test_literals.rb +20 -10
  21. data/test/lexer/test_nesting.rb +14 -7
  22. data/test/lexer/test_refcalls.rb +12 -5
  23. data/test/parser/test_all.rb +15 -13
  24. data/test/parser/test_alternation.rb +29 -26
  25. data/test/parser/test_anchors.rb +7 -8
  26. data/test/parser/test_conditionals.rb +43 -41
  27. data/test/parser/test_escapes.rb +18 -16
  28. data/test/parser/test_free_space.rb +33 -33
  29. data/test/parser/test_groups.rb +46 -46
  30. data/test/parser/test_keep.rb +4 -4
  31. data/test/parser/test_properties.rb +18 -16
  32. data/test/parser/test_quantifiers.rb +184 -163
  33. data/test/parser/test_refcalls.rb +48 -32
  34. data/test/parser/test_sets.rb +102 -88
  35. data/test/parser/test_types.rb +7 -8
  36. data/test/scanner/test_all.rb +6 -4
  37. data/test/scanner/test_anchors.rb +8 -5
  38. data/test/scanner/test_conditionals.rb +38 -20
  39. data/test/scanner/test_escapes.rb +8 -6
  40. data/test/scanner/test_free_space.rb +89 -65
  41. data/test/scanner/test_groups.rb +27 -32
  42. data/test/scanner/test_keep.rb +24 -22
  43. data/test/scanner/test_literals.rb +11 -7
  44. data/test/scanner/test_meta.rb +11 -7
  45. data/test/scanner/test_properties.rb +16 -14
  46. data/test/scanner/test_quantifiers.rb +8 -9
  47. data/test/scanner/test_refcalls.rb +26 -23
  48. data/test/scanner/test_scripts.rb +11 -10
  49. data/test/scanner/test_sets.rb +8 -5
  50. data/test/scanner/test_types.rb +17 -15
  51. data/test/scanner/test_unicode_blocks.rb +11 -10
  52. data/test/syntax/ruby/test_1.8.rb +4 -8
  53. data/test/syntax/ruby/test_1.9.1.rb +1 -7
  54. data/test/syntax/ruby/test_1.9.3.rb +3 -7
  55. data/test/syntax/ruby/test_2.0.0.rb +1 -7
  56. data/test/syntax/ruby/test_2.2.0.rb +1 -7
  57. data/test/token/test_token.rb +29 -31
  58. metadata +3 -3
@@ -10,7 +10,8 @@ class ExpressionFreeSpace < Test::Unit::TestCase
10
10
  root = RP.parse(regexp)
11
11
 
12
12
  space = root[0]
13
- assert_equal( FreeSpace::WhiteSpace, space.class )
13
+ assert_equal FreeSpace::WhiteSpace, space.class
14
+
14
15
  assert_raise( RuntimeError ) {
15
16
  space.quantify(:dummy, '#')
16
17
  }
@@ -24,7 +25,8 @@ class ExpressionFreeSpace < Test::Unit::TestCase
24
25
  root = RP.parse(regexp)
25
26
 
26
27
  comment = root[3]
27
- assert_equal( FreeSpace::Comment, comment.class )
28
+ assert_equal FreeSpace::Comment, comment.class
29
+
28
30
  assert_raise( RuntimeError ) {
29
31
  comment.quantify(:dummy, '#')
30
32
  }
@@ -5,57 +5,57 @@ class ExpressionSet < Test::Unit::TestCase
5
5
  def test_expression_set_exapnd_members_digit
6
6
  set = RP.parse('[\d]').first
7
7
 
8
- assert_equal( ['0-9'], set.expand_members )
9
- assert_equal( ['\p{Digit}'], set.expand_members(true) )
8
+ assert_equal ['0-9'], set.expand_members
9
+ assert_equal ['\p{Digit}'], set.expand_members(true)
10
10
  end
11
11
 
12
12
  def test_expression_set_exapnd_members_nondigit
13
13
  set = RP.parse('[\D]').first
14
14
 
15
- assert_equal( ['^0-9'], set.expand_members )
16
- assert_equal( ['\P{Digit}'], set.expand_members(true) )
15
+ assert_equal ['^0-9'], set.expand_members
16
+ assert_equal ['\P{Digit}'], set.expand_members(true)
17
17
  end
18
18
 
19
19
  def test_expression_set_exapnd_members_word
20
20
  set = RP.parse('[\w]').first
21
21
 
22
- assert_equal( ['A-Za-z0-9_'], set.expand_members )
23
- assert_equal( ['\p{Word}'], set.expand_members(true) )
22
+ assert_equal ['A-Za-z0-9_'], set.expand_members
23
+ assert_equal ['\p{Word}'], set.expand_members(true)
24
24
  end
25
25
 
26
26
  def test_expression_set_exapnd_members_nonword
27
27
  set = RP.parse('[\W]').first
28
28
 
29
- assert_equal( ['^A-Za-z0-9_'], set.expand_members )
30
- assert_equal( ['\P{Word}'], set.expand_members(true) )
29
+ assert_equal ['^A-Za-z0-9_'], set.expand_members
30
+ assert_equal ['\P{Word}'], set.expand_members(true)
31
31
  end
32
32
 
33
33
  def test_expression_set_exapnd_members_space
34
34
  set = RP.parse('[\s]').first
35
35
 
36
- assert_equal( [' \t\f\v\n\r'], set.expand_members )
37
- assert_equal( ['\p{Space}'], set.expand_members(true) )
36
+ assert_equal [' \t\f\v\n\r'], set.expand_members
37
+ assert_equal ['\p{Space}'], set.expand_members(true)
38
38
  end
39
39
 
40
40
  def test_expression_set_exapnd_members_nonspace
41
41
  set = RP.parse('[\S]').first
42
42
 
43
- assert_equal( ['^ \t\f\v\n\r'], set.expand_members )
44
- assert_equal( ['\P{Space}'], set.expand_members(true) )
43
+ assert_equal ['^ \t\f\v\n\r'], set.expand_members
44
+ assert_equal ['\P{Space}'], set.expand_members(true)
45
45
  end
46
46
 
47
47
  def test_expression_set_exapnd_members_xdigit
48
48
  set = RP.parse('[\h]').first
49
49
 
50
- assert_equal( ['0-9A-Fa-f'], set.expand_members )
51
- assert_equal( ['\p{Xdigit}'], set.expand_members(true) )
50
+ assert_equal ['0-9A-Fa-f'], set.expand_members
51
+ assert_equal ['\p{Xdigit}'], set.expand_members(true)
52
52
  end
53
53
 
54
54
  def test_expression_set_exapnd_members_nonxdigit
55
55
  set = RP.parse('[\H]').first
56
56
 
57
- assert_equal( ['^0-9A-Fa-f'], set.expand_members )
58
- assert_equal( ['\P{Xdigit}'], set.expand_members(true) )
57
+ assert_equal ['^0-9A-Fa-f'], set.expand_members
58
+ assert_equal ['\P{Xdigit}'], set.expand_members(true)
59
59
  end
60
60
 
61
61
  end
@@ -3,168 +3,168 @@ require File.expand_path("../../helpers", __FILE__)
3
3
  class Expressionstrfregexp < Test::Unit::TestCase
4
4
 
5
5
  def test_expression_strfre_alias
6
- assert_equal( true, RP.parse(/a/).respond_to?(:strfre) )
6
+ assert_equal true, RP.parse(/a/).respond_to?(:strfre)
7
7
  end
8
8
 
9
9
  def test_expression_strfregexp_level
10
10
  root = RP.parse(/a(b(c))/)
11
11
 
12
- assert_equal( 'root', root.strfregexp('%l') )
12
+ assert_equal 'root', root.strfregexp('%l')
13
13
 
14
14
  a = root.first
15
- assert_equal( '%0', a.strfregexp('%%l') )
15
+ assert_equal '%0', a.strfregexp('%%l')
16
16
 
17
17
  b = root[1].first
18
- assert_equal( '<1>', b.strfregexp('<%l>') )
18
+ assert_equal '<1>', b.strfregexp('<%l>')
19
19
 
20
20
  c = root[1][1].first
21
- assert_equal( '[at: 2]', c.strfregexp('[at: %l]') )
21
+ assert_equal '[at: 2]', c.strfregexp('[at: %l]')
22
22
  end
23
23
 
24
24
  def test_expression_strfregexp_start_end
25
25
  root = RP.parse(/a(b(c))/)
26
26
 
27
- assert_equal( '0', root.strfregexp('%s') )
28
- assert_equal( '7', root.strfregexp('%e') )
27
+ assert_equal '0', root.strfregexp('%s')
28
+ assert_equal '7', root.strfregexp('%e')
29
29
 
30
30
  a = root.first
31
- assert_equal( '%0', a.strfregexp('%%s') )
32
- assert_equal( '1', a.strfregexp('%e') )
31
+ assert_equal '%0', a.strfregexp('%%s')
32
+ assert_equal '1', a.strfregexp('%e')
33
33
 
34
34
  group_1 = root[1]
35
- assert_equal( 'GRP:1', group_1.strfregexp('GRP:%s') )
36
- assert_equal( '7', group_1.strfregexp('%e') )
35
+ assert_equal 'GRP:1', group_1.strfregexp('GRP:%s')
36
+ assert_equal '7', group_1.strfregexp('%e')
37
37
 
38
38
  b = group_1.first
39
- assert_equal( '<@2>', b.strfregexp('<@%s>') )
40
- assert_equal( '3', b.strfregexp('%e') )
39
+ assert_equal '<@2>', b.strfregexp('<@%s>')
40
+ assert_equal '3', b.strfregexp('%e')
41
41
 
42
42
  c = group_1.last.first
43
- assert_equal( '[at: 4]', c.strfregexp('[at: %s]') )
44
- assert_equal( '5', c.strfregexp('%e') )
43
+ assert_equal '[at: 4]', c.strfregexp('[at: %s]')
44
+ assert_equal '5', c.strfregexp('%e')
45
45
  end
46
46
 
47
47
  def test_expression_strfregexp_length
48
48
  root = RP.parse(/a[b]c/)
49
49
 
50
- assert_equal( '5', root.strfregexp('%S') )
50
+ assert_equal '5', root.strfregexp('%S')
51
51
 
52
52
  a = root.first
53
- assert_equal( '1', a.strfregexp('%S') )
53
+ assert_equal '1', a.strfregexp('%S')
54
54
 
55
55
  set = root[1]
56
- assert_equal( '3', set.strfregexp('%S') )
56
+ assert_equal '3', set.strfregexp('%S')
57
57
  end
58
58
 
59
59
  def test_expression_strfregexp_coded_offset
60
60
  root = RP.parse(/a[b]c/)
61
61
 
62
- assert_equal( '@0+5', root.strfregexp('%o') )
62
+ assert_equal '@0+5', root.strfregexp('%o')
63
63
 
64
64
  a = root.first
65
- assert_equal( '@0+1', a.strfregexp('%o') )
65
+ assert_equal '@0+1', a.strfregexp('%o')
66
66
 
67
67
  set = root[1]
68
- assert_equal( '@1+3', set.strfregexp('%o') )
68
+ assert_equal '@1+3', set.strfregexp('%o')
69
69
  end
70
70
 
71
71
  def test_expression_strfregexp_type_token
72
72
  root = RP.parse(/a[b](c)/)
73
73
 
74
- assert_equal( 'expression', root.strfregexp('%y') )
75
- assert_equal( 'root', root.strfregexp('%k') )
76
- assert_equal( 'expression:root', root.strfregexp('%i') )
77
- assert_equal( 'Regexp::Expression::Root', root.strfregexp('%c') )
74
+ assert_equal 'expression', root.strfregexp('%y')
75
+ assert_equal 'root', root.strfregexp('%k')
76
+ assert_equal 'expression:root', root.strfregexp('%i')
77
+ assert_equal 'Regexp::Expression::Root', root.strfregexp('%c')
78
78
 
79
79
  a = root.first
80
- assert_equal( 'literal', a.strfregexp('%y') )
81
- assert_equal( 'literal', a.strfregexp('%k') )
82
- assert_equal( 'literal:literal', a.strfregexp('%i') )
83
- assert_equal( 'Regexp::Expression::Literal', a.strfregexp('%c') )
80
+ assert_equal 'literal', a.strfregexp('%y')
81
+ assert_equal 'literal', a.strfregexp('%k')
82
+ assert_equal 'literal:literal', a.strfregexp('%i')
83
+ assert_equal 'Regexp::Expression::Literal', a.strfregexp('%c')
84
84
 
85
85
  set = root[1]
86
- assert_equal( 'set', set.strfregexp('%y') )
87
- assert_equal( 'character', set.strfregexp('%k') )
88
- assert_equal( 'set:character', set.strfregexp('%i') )
89
- assert_equal( 'Regexp::Expression::CharacterSet', set.strfregexp('%c') )
86
+ assert_equal 'set', set.strfregexp('%y')
87
+ assert_equal 'character', set.strfregexp('%k')
88
+ assert_equal 'set:character', set.strfregexp('%i')
89
+ assert_equal 'Regexp::Expression::CharacterSet', set.strfregexp('%c')
90
90
 
91
91
  group = root.last
92
- assert_equal( 'group', group.strfregexp('%y') )
93
- assert_equal( 'capture', group.strfregexp('%k') )
94
- assert_equal( 'group:capture', group.strfregexp('%i') )
95
- assert_equal( 'Regexp::Expression::Group::Capture', group.strfregexp('%c') )
92
+ assert_equal 'group', group.strfregexp('%y')
93
+ assert_equal 'capture', group.strfregexp('%k')
94
+ assert_equal 'group:capture', group.strfregexp('%i')
95
+ assert_equal 'Regexp::Expression::Group::Capture', group.strfregexp('%c')
96
96
  end
97
97
 
98
98
  def test_expression_strfregexp_quantifier
99
99
  root = RP.parse(/a+[b](c)?d{3,4}/)
100
100
 
101
- assert_equal( '{1}', root.strfregexp('%q') )
102
- assert_equal( '', root.strfregexp('%Q') )
103
- assert_equal( '1, 1', root.strfregexp('%z, %Z') )
101
+ assert_equal '{1}', root.strfregexp('%q')
102
+ assert_equal '', root.strfregexp('%Q')
103
+ assert_equal '1, 1', root.strfregexp('%z, %Z')
104
104
 
105
105
  a = root.first
106
- assert_equal( '{1, or-more}', a.strfregexp('%q') )
107
- assert_equal( '+', a.strfregexp('%Q') )
108
- assert_equal( '1, -1', a.strfregexp('%z, %Z') )
106
+ assert_equal '{1, or-more}', a.strfregexp('%q')
107
+ assert_equal '+', a.strfregexp('%Q')
108
+ assert_equal '1, -1', a.strfregexp('%z, %Z')
109
109
 
110
110
  set = root[1]
111
- assert_equal( '{1}', set.strfregexp('%q') )
112
- assert_equal( '', set.strfregexp('%Q') )
113
- assert_equal( '1, 1', set.strfregexp('%z, %Z') )
111
+ assert_equal '{1}', set.strfregexp('%q')
112
+ assert_equal '', set.strfregexp('%Q')
113
+ assert_equal '1, 1', set.strfregexp('%z, %Z')
114
114
 
115
115
  group = root[2]
116
- assert_equal( '{0, 1}', group.strfregexp('%q') )
117
- assert_equal( '?', group.strfregexp('%Q') )
118
- assert_equal( '0, 1', group.strfregexp('%z, %Z') )
116
+ assert_equal '{0, 1}', group.strfregexp('%q')
117
+ assert_equal '?', group.strfregexp('%Q')
118
+ assert_equal '0, 1', group.strfregexp('%z, %Z')
119
119
 
120
120
  d = root.last
121
- assert_equal( '{3, 4}', d.strfregexp('%q') )
122
- assert_equal( '{3,4}', d.strfregexp('%Q') )
123
- assert_equal( '3, 4', d.strfregexp('%z, %Z') )
121
+ assert_equal '{3, 4}', d.strfregexp('%q')
122
+ assert_equal '{3,4}', d.strfregexp('%Q')
123
+ assert_equal '3, 4', d.strfregexp('%z, %Z')
124
124
  end
125
125
 
126
126
  def test_expression_strfregexp_text
127
127
  root = RP.parse(/a(b(c))|[d-gk-p]+/)
128
128
 
129
- assert_equal( 'a(b(c))|[d-gk-p]+', root.strfregexp('%t') )
130
- assert_equal( 'expression:root', root.strfregexp('%~t') )
129
+ assert_equal 'a(b(c))|[d-gk-p]+', root.strfregexp('%t')
130
+ assert_equal 'expression:root', root.strfregexp('%~t')
131
131
 
132
132
  alt = root.first
133
- assert_equal( 'a(b(c))|[d-gk-p]+', alt.strfregexp('%t') )
134
- assert_equal( 'a(b(c))|[d-gk-p]+', alt.strfregexp('%T') )
135
- assert_equal( 'meta:alternation', alt.strfregexp('%~t') )
133
+ assert_equal 'a(b(c))|[d-gk-p]+', alt.strfregexp('%t')
134
+ assert_equal 'a(b(c))|[d-gk-p]+', alt.strfregexp('%T')
135
+ assert_equal 'meta:alternation', alt.strfregexp('%~t')
136
136
 
137
137
  seq_1 = alt.first
138
- assert_equal( 'a(b(c))', seq_1.strfregexp('%t') )
139
- assert_equal( 'a(b(c))', seq_1.strfregexp('%T') )
140
- assert_equal( 'expression:sequence', seq_1.strfregexp('%~t') )
138
+ assert_equal 'a(b(c))', seq_1.strfregexp('%t')
139
+ assert_equal 'a(b(c))', seq_1.strfregexp('%T')
140
+ assert_equal 'expression:sequence', seq_1.strfregexp('%~t')
141
141
 
142
142
  group = seq_1[1]
143
- assert_equal( '(b(c))', group.strfregexp('%t') )
144
- assert_equal( '(b(c))', group.strfregexp('%T') )
145
- assert_equal( 'group:capture', group.strfregexp('%~t') )
143
+ assert_equal '(b(c))', group.strfregexp('%t')
144
+ assert_equal '(b(c))', group.strfregexp('%T')
145
+ assert_equal 'group:capture', group.strfregexp('%~t')
146
146
 
147
147
  seq_2 = alt.last
148
- assert_equal( '[d-gk-p]+', seq_2.strfregexp('%t') )
149
- assert_equal( '[d-gk-p]+', seq_2.strfregexp('%T') )
148
+ assert_equal '[d-gk-p]+', seq_2.strfregexp('%t')
149
+ assert_equal '[d-gk-p]+', seq_2.strfregexp('%T')
150
150
 
151
151
  set = seq_2.first
152
- assert_equal( '[d-gk-p]', set.strfregexp('%t') )
153
- assert_equal( '[d-gk-p]+', set.strfregexp('%T') )
154
- assert_equal( '[d-gk-p]+', set.strfregexp('%~t') )
152
+ assert_equal '[d-gk-p]', set.strfregexp('%t')
153
+ assert_equal '[d-gk-p]+', set.strfregexp('%T')
154
+ assert_equal '[d-gk-p]+', set.strfregexp('%~t')
155
155
  end
156
156
 
157
157
  def test_expression_strfregexp_combined
158
158
  root = RP.parse(/a{5}|[b-d]+/)
159
159
 
160
- assert_equal( '@0+11 expression:root', root.strfregexp('%b') )
161
- assert_equal( root.strfregexp('%o %i'), root.strfregexp('%b') )
160
+ assert_equal '@0+11 expression:root', root.strfregexp('%b')
161
+ assert_equal root.strfregexp('%o %i'), root.strfregexp('%b')
162
162
 
163
- assert_equal( '@0+11 expression:root {1}', root.strfregexp('%m') )
164
- assert_equal( root.strfregexp('%b %q'), root.strfregexp('%m') )
163
+ assert_equal '@0+11 expression:root {1}', root.strfregexp('%m')
164
+ assert_equal root.strfregexp('%b %q'), root.strfregexp('%m')
165
165
 
166
- assert_equal( '@0+11 expression:root {1} a{5}|[b-d]+', root.strfregexp('%a') )
167
- assert_equal( root.strfregexp('%m %t'), root.strfregexp('%a') )
166
+ assert_equal '@0+11 expression:root {1} a{5}|[b-d]+', root.strfregexp('%a')
167
+ assert_equal root.strfregexp('%m %t'), root.strfregexp('%a')
168
168
  end
169
169
 
170
170
  def test_expression_strfregexp_tree
@@ -16,8 +16,8 @@ class ExpressionSubexpression < Test::Unit::TestCase
16
16
  }.each do |index, span|
17
17
  sequence = alt[index]
18
18
 
19
- assert_equal( span[0], sequence.ts )
20
- assert_equal( span[1], sequence.te )
19
+ assert_equal span[0], sequence.ts
20
+ assert_equal span[1], sequence.te
21
21
  end
22
22
  end
23
23
 
@@ -7,93 +7,93 @@ class ExpressionTests < Test::Unit::TestCase
7
7
 
8
8
  alt = root.first
9
9
 
10
- assert_equal( true, alt.type?(:meta) )
11
- assert_equal( false, alt.type?(:escape) )
12
- assert_equal( true, alt.type?([:meta, :escape]) )
13
- assert_equal( false, alt.type?([:literal, :escape]) )
14
- assert_equal( true, alt.type?(:*) )
15
- assert_equal( true, alt.type?([:*]) )
16
- assert_equal( true, alt.type?([:literal, :escape, :*]) )
10
+ assert_equal true, alt.type?(:meta)
11
+ assert_equal false, alt.type?(:escape)
12
+ assert_equal true, alt.type?([:meta, :escape])
13
+ assert_equal false, alt.type?([:literal, :escape])
14
+ assert_equal true, alt.type?(:*)
15
+ assert_equal true, alt.type?([:*])
16
+ assert_equal true, alt.type?([:literal, :escape, :*])
17
17
 
18
18
  seq_1 = alt[0]
19
- assert_equal( true, seq_1.type?(:expression) )
20
- assert_equal( true, seq_1.first.type?(:literal) )
19
+ assert_equal true, seq_1.type?(:expression)
20
+ assert_equal true, seq_1.first.type?(:literal)
21
21
 
22
22
  seq_2 = alt[1]
23
- assert_equal( true, seq_2.type?(:*) )
24
- assert_equal( true, seq_2.first.type?(:group) )
23
+ assert_equal true, seq_2.type?(:*)
24
+ assert_equal true, seq_2.first.type?(:group)
25
25
 
26
26
  seq_3 = alt[2]
27
- assert_equal( true, seq_3.first.type?(:set) )
27
+ assert_equal true, seq_3.first.type?(:set)
28
28
  end
29
29
 
30
30
  def test_expression_is?
31
31
  root = RP.parse(/.+|\.?/)
32
32
 
33
- assert_equal( true, root.is?(:*) )
33
+ assert_equal true, root.is?(:*)
34
34
 
35
35
  alt = root.first
36
- assert_equal( true, alt.is?(:*) )
37
- assert_equal( true, alt.is?(:alternation) )
38
- assert_equal( true, alt.is?(:alternation, :meta) )
36
+ assert_equal true, alt.is?(:*)
37
+ assert_equal true, alt.is?(:alternation)
38
+ assert_equal true, alt.is?(:alternation, :meta)
39
39
 
40
40
  seq_1 = alt[0]
41
- assert_equal( true, seq_1.is?(:sequence) )
42
- assert_equal( true, seq_1.is?(:sequence, :expression) )
41
+ assert_equal true, seq_1.is?(:sequence)
42
+ assert_equal true, seq_1.is?(:sequence, :expression)
43
43
 
44
- assert_equal( true, seq_1.first.is?(:dot) )
45
- assert_equal( false, seq_1.first.is?(:dot, :escape) )
46
- assert_equal( true, seq_1.first.is?(:dot, :meta) )
47
- assert_equal( true, seq_1.first.is?(:dot, [:escape, :meta]) )
44
+ assert_equal true, seq_1.first.is?(:dot)
45
+ assert_equal false, seq_1.first.is?(:dot, :escape)
46
+ assert_equal true, seq_1.first.is?(:dot, :meta)
47
+ assert_equal true, seq_1.first.is?(:dot, [:escape, :meta])
48
48
 
49
49
  seq_2 = alt[1]
50
- assert_equal( true, seq_2.first.is?(:dot) )
51
- assert_equal( true, seq_2.first.is?(:dot, :escape) )
52
- assert_equal( false, seq_2.first.is?(:dot, :meta) )
53
- assert_equal( true, seq_2.first.is?(:dot, [:meta, :escape]) )
50
+ assert_equal true, seq_2.first.is?(:dot)
51
+ assert_equal true, seq_2.first.is?(:dot, :escape)
52
+ assert_equal false, seq_2.first.is?(:dot, :meta)
53
+ assert_equal true, seq_2.first.is?(:dot, [:meta, :escape])
54
54
  end
55
55
 
56
56
  def test_expression_one_of?
57
57
  root = RP.parse(/\Aab(c[\w])d|e.\z/)
58
58
 
59
- assert_equal( true, root.one_of?(:*) )
60
- assert_equal( true, root.one_of?(:* => :*) )
61
- assert_equal( true, root.one_of?(:* => [:*]) )
59
+ assert_equal true, root.one_of?(:*)
60
+ assert_equal true, root.one_of?(:* => :*)
61
+ assert_equal true, root.one_of?(:* => [:*])
62
62
 
63
63
  alt = root.first
64
- assert_equal( true, alt.one_of?(:*) )
65
- assert_equal( true, alt.one_of?(:meta) )
66
- assert_equal( true, alt.one_of?(:meta, :alternation) )
67
- assert_equal( false, alt.one_of?(:meta => [:dot, :bogus]) )
68
- assert_equal( true, alt.one_of?(:meta => [:dot, :alternation]) )
64
+ assert_equal true, alt.one_of?(:*)
65
+ assert_equal true, alt.one_of?(:meta)
66
+ assert_equal true, alt.one_of?(:meta, :alternation)
67
+ assert_equal false, alt.one_of?(:meta => [:dot, :bogus])
68
+ assert_equal true, alt.one_of?(:meta => [:dot, :alternation])
69
69
 
70
70
  seq_1 = alt[0]
71
- assert_equal( true, seq_1.one_of?(:expression) )
72
- assert_equal( true, seq_1.one_of?(:expression => :sequence) )
71
+ assert_equal true, seq_1.one_of?(:expression)
72
+ assert_equal true, seq_1.one_of?(:expression => :sequence)
73
73
 
74
- assert_equal( true, seq_1.first.one_of?(:anchor) )
75
- assert_equal( true, seq_1.first.one_of?(:anchor => :bos) )
76
- assert_equal( false, seq_1.first.one_of?(:anchor => :eos) )
77
- assert_equal( true, seq_1.first.one_of?(:anchor => [:escape, :meta, :bos]) )
78
- assert_equal( false, seq_1.first.one_of?(:anchor => [:escape, :meta, :eos]) )
74
+ assert_equal true, seq_1.first.one_of?(:anchor)
75
+ assert_equal true, seq_1.first.one_of?(:anchor => :bos)
76
+ assert_equal false, seq_1.first.one_of?(:anchor => :eos)
77
+ assert_equal true, seq_1.first.one_of?(:anchor => [:escape, :meta, :bos])
78
+ assert_equal false, seq_1.first.one_of?(:anchor => [:escape, :meta, :eos])
79
79
 
80
80
  seq_2 = alt[1]
81
- assert_equal( true, seq_2.first.one_of?(:literal) )
82
-
83
- assert_equal( true, seq_2[1].one_of?(:meta) )
84
- assert_equal( true, seq_2[1].one_of?(:meta => :dot) )
85
- assert_equal( false, seq_2[1].one_of?(:meta => :alternation) )
86
- assert_equal( true, seq_2[1].one_of?(:meta => [:dot]) )
87
-
88
- assert_equal( false, seq_2.last.one_of?(:group) )
89
- assert_equal( false, seq_2.last.one_of?(:group => [:*]) )
90
- assert_equal( false, seq_2.last.one_of?(:group => [:*], :meta => :*) )
91
-
92
- assert_equal( true, seq_2.last.one_of?(:meta => [:*], :* => :*) )
93
- assert_equal( true, seq_2.last.one_of?(:meta => [:*], :anchor => :*) )
94
- assert_equal( true, seq_2.last.one_of?(:meta => [:*], :anchor => :eos) )
95
- assert_equal( false, seq_2.last.one_of?(:meta => [:*], :anchor => [:bos]) )
96
- assert_equal( true, seq_2.last.one_of?(:meta => [:*], :anchor => [:bos, :eos]) )
81
+ assert_equal true, seq_2.first.one_of?(:literal)
82
+
83
+ assert_equal true, seq_2[1].one_of?(:meta)
84
+ assert_equal true, seq_2[1].one_of?(:meta => :dot)
85
+ assert_equal false, seq_2[1].one_of?(:meta => :alternation)
86
+ assert_equal true, seq_2[1].one_of?(:meta => [:dot])
87
+
88
+ assert_equal false, seq_2.last.one_of?(:group)
89
+ assert_equal false, seq_2.last.one_of?(:group => [:*])
90
+ assert_equal false, seq_2.last.one_of?(:group => [:*], :meta => :*)
91
+
92
+ assert_equal true, seq_2.last.one_of?(:meta => [:*], :* => :*)
93
+ assert_equal true, seq_2.last.one_of?(:meta => [:*], :anchor => :*)
94
+ assert_equal true, seq_2.last.one_of?(:meta => [:*], :anchor => :eos)
95
+ assert_equal false, seq_2.last.one_of?(:meta => [:*], :anchor => [:bos])
96
+ assert_equal true, seq_2.last.one_of?(:meta => [:*], :anchor => [:bos, :eos])
97
97
  end
98
98
 
99
99
  end