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
@@ -3,99 +3,115 @@ require File.expand_path("../../helpers", __FILE__)
3
3
  class TestParserRefcalls < Test::Unit::TestCase
4
4
 
5
5
  def test_parse_backref_named_ab
6
- t = RP.parse('(?<X>abc)\k<X>', 'ruby/1.9')[1]
6
+ root = RP.parse('(?<X>abc)\k<X>', 'ruby/1.9')
7
+ exp = root.expressions.at(1)
7
8
 
8
- assert_equal( true, t.is_a?(Backreference::Name) )
9
+ assert_equal true, exp.is_a?(Backreference::Name)
9
10
  end
10
11
 
11
12
  def test_parse_backref_named_sq
12
- t = RP.parse("(?<X>abc)\\k'X'", 'ruby/1.9')[1]
13
+ root = RP.parse("(?<X>abc)\\k'X'", 'ruby/1.9')
14
+ exp = root.expressions.at(1)
13
15
 
14
- assert_equal( true, t.is_a?(Backreference::Name) )
16
+ assert_equal true, exp.is_a?(Backreference::Name)
15
17
  end
16
18
 
17
19
  def test_parse_backref_number_ab
18
- t = RP.parse('(abc)\k<1>', 'ruby/1.9')[1]
20
+ root = RP.parse('(abc)\k<1>', 'ruby/1.9')
21
+ exp = root.expressions.at(1)
19
22
 
20
- assert_equal( true, t.is_a?(Backreference::Number) )
23
+ assert_equal true, exp.is_a?(Backreference::Number)
21
24
  end
22
25
 
23
26
  def test_parse_backref_number_sq
24
- t = RP.parse("(abc)\\k'1'", 'ruby/1.9')[1]
27
+ root = RP.parse("(abc)\\k'1'", 'ruby/1.9')
28
+ exp = root.expressions.at(1)
25
29
 
26
- assert_equal( true, t.is_a?(Backreference::Number) )
30
+ assert_equal true, exp.is_a?(Backreference::Number)
27
31
  end
28
32
 
29
33
  def test_parse_backref_number_relative_ab
30
- t = RP.parse('(abc)\k<-1>', 'ruby/1.9')[1]
34
+ root = RP.parse('(abc)\k<-1>', 'ruby/1.9')
35
+ exp = root.expressions.at(1)
31
36
 
32
- assert_equal( true, t.is_a?(Backreference::NumberRelative) )
37
+ assert_equal true, exp.is_a?(Backreference::NumberRelative)
33
38
  end
34
39
 
35
40
  def test_parse_backref_number_relative_sq
36
- t = RP.parse("(abc)\\k'-1'", 'ruby/1.9')[1]
41
+ root = RP.parse("(abc)\\k'-1'", 'ruby/1.9')
42
+ exp = root.expressions.at(1)
37
43
 
38
- assert_equal( true, t.is_a?(Backreference::NumberRelative) )
44
+ assert_equal true, exp.is_a?(Backreference::NumberRelative)
39
45
  end
40
46
 
41
47
  def test_parse_backref_name_call_ab
42
- t = RP.parse('(?<X>abc)\g<X>', 'ruby/1.9')[1]
48
+ root = RP.parse('(?<X>abc)\g<X>', 'ruby/1.9')
49
+ exp = root.expressions.at(1)
43
50
 
44
- assert_equal( true, t.is_a?(Backreference::NameCall) )
51
+ assert_equal true, exp.is_a?(Backreference::NameCall)
45
52
  end
46
53
 
47
54
  def test_parse_backref_name_call_sq
48
- t = RP.parse("(?<X>abc)\\g'X'", 'ruby/1.9')[1]
55
+ root = RP.parse("(?<X>abc)\\g'X'", 'ruby/1.9')
56
+ exp = root.expressions.at(1)
49
57
 
50
- assert_equal( true, t.is_a?(Backreference::NameCall) )
58
+ assert_equal true, exp.is_a?(Backreference::NameCall)
51
59
  end
52
60
 
53
61
  def test_parse_backref_number_call_ab
54
- t = RP.parse('(abc)\g<1>', 'ruby/1.9')[1]
62
+ root = RP.parse('(abc)\g<1>', 'ruby/1.9')
63
+ exp = root.expressions.at(1)
55
64
 
56
- assert_equal( true, t.is_a?(Backreference::NumberCall) )
65
+ assert_equal true, exp.is_a?(Backreference::NumberCall)
57
66
  end
58
67
 
59
68
  def test_parse_backref_number_call_sq
60
- t = RP.parse("(abc)\\g'1'", 'ruby/1.9')[1]
69
+ root = RP.parse("(abc)\\g'1'", 'ruby/1.9')
70
+ exp = root.expressions.at(1)
61
71
 
62
- assert_equal( true, t.is_a?(Backreference::NumberCall) )
72
+ assert_equal true, exp.is_a?(Backreference::NumberCall)
63
73
  end
64
74
 
65
75
  def test_parse_backref_number_relative_call_ab
66
- t = RP.parse('(abc)\g<-1>', 'ruby/1.9')[1]
76
+ root = RP.parse('(abc)\g<-1>', 'ruby/1.9')
77
+ exp = root.expressions.at(1)
67
78
 
68
- assert_equal( true, t.is_a?(Backreference::NumberCallRelative) )
79
+ assert_equal true, exp.is_a?(Backreference::NumberCallRelative)
69
80
  end
70
81
 
71
82
  def test_parse_backref_number_relative_call_sq
72
- t = RP.parse("(abc)\\g'-1'", 'ruby/1.9')[1]
83
+ root = RP.parse("(abc)\\g'-1'", 'ruby/1.9')
84
+ exp = root.expressions.at(1)
73
85
 
74
- assert_equal( true, t.is_a?(Backreference::NumberCallRelative) )
86
+ assert_equal true, exp.is_a?(Backreference::NumberCallRelative)
75
87
  end
76
88
 
77
89
  def test_parse_backref_name_nest_level_ab
78
- t = RP.parse('(?<X>abc)\k<X-0>', 'ruby/1.9')[1]
90
+ root = RP.parse('(?<X>abc)\k<X-0>', 'ruby/1.9')
91
+ exp = root.expressions.at(1)
79
92
 
80
- assert_equal( true, t.is_a?(Backreference::NameNestLevel) )
93
+ assert_equal true, exp.is_a?(Backreference::NameNestLevel)
81
94
  end
82
95
 
83
96
  def test_parse_backref_name_nest_level_sq
84
- t = RP.parse("(?<X>abc)\\k'X-0'", 'ruby/1.9')[1]
97
+ root = RP.parse("(?<X>abc)\\k'X-0'", 'ruby/1.9')
98
+ exp = root.expressions.at(1)
85
99
 
86
- assert_equal( true, t.is_a?(Backreference::NameNestLevel) )
100
+ assert_equal true, exp.is_a?(Backreference::NameNestLevel)
87
101
  end
88
102
 
89
103
  def test_parse_backref_number_nest_level_ab
90
- t = RP.parse('(abc)\k<1-0>', 'ruby/1.9')[1]
104
+ root = RP.parse('(abc)\k<1-0>', 'ruby/1.9')
105
+ exp = root.expressions.at(1)
91
106
 
92
- assert_equal( true, t.is_a?(Backreference::NumberNestLevel) )
107
+ assert_equal true, exp.is_a?(Backreference::NumberNestLevel)
93
108
  end
94
109
 
95
110
  def test_parse_backref_number_nest_level_sq
96
- t = RP.parse("(abc)\\k'1-0'", 'ruby/1.9')[1]
111
+ root = RP.parse("(abc)\\k'1-0'", 'ruby/1.9')
112
+ exp = root.expressions.at(1)
97
113
 
98
- assert_equal( true, t.is_a?(Backreference::NumberNestLevel) )
114
+ assert_equal true, exp.is_a?(Backreference::NumberNestLevel)
99
115
  end
100
116
 
101
117
  end
@@ -3,149 +3,163 @@ require File.expand_path("../../helpers", __FILE__)
3
3
  class TestParserSets < Test::Unit::TestCase
4
4
 
5
5
  def test_parse_set_basic
6
- exp = RP.parse('[a-c]+', :any).expressions[0]
6
+ root = RP.parse('[a-c]+', :any)
7
+ exp = root.expressions.at(0)
7
8
 
8
- assert_equal( true, exp.is_a?(CharacterSet) )
9
- assert_equal( true, exp.include?('a-c') )
9
+ assert_equal true, exp.is_a?(CharacterSet)
10
+ assert_equal true, exp.include?('a-c')
10
11
 
11
- assert_equal( true, exp.quantified? )
12
- assert_equal( 1, exp.quantifier.min )
13
- assert_equal( -1, exp.quantifier.max )
12
+ assert_equal true, exp.quantified?
13
+ assert_equal 1, exp.quantifier.min
14
+ assert_equal -1, exp.quantifier.max
14
15
  end
15
16
 
16
17
  def test_parse_set_posix_class
17
- exp = RP.parse('[[:digit:][:lower:]]+', 'ruby/1.9').expressions[0]
18
+ root = RP.parse('[[:digit:][:lower:]]+', 'ruby/1.9')
19
+ exp = root.expressions.at(0)
18
20
 
19
- assert_equal( true, exp.is_a?(CharacterSet) )
21
+ assert_equal true, exp.is_a?(CharacterSet)
20
22
 
21
- assert_equal( true, exp.include?('[:digit:]') )
22
- assert_equal( true, exp.include?('[:lower:]') )
23
+ assert_equal true, exp.include?('[:digit:]')
24
+ assert_equal true, exp.include?('[:lower:]')
23
25
 
24
- assert_equal( true, exp.matches?("6") )
26
+ assert_equal true, exp.matches?("6")
25
27
 
26
- assert_equal( true, exp.matches?("v") )
27
- assert_equal( false, exp.matches?("\x48") )
28
+ assert_equal true, exp.matches?("v")
29
+ assert_equal false, exp.matches?("\x48")
28
30
  end
29
31
 
30
32
  def test_parse_set_members
31
- exp = RP.parse('[ac-eh]', :any)[0]
33
+ root = RP.parse('[ac-eh]', :any)
34
+ exp = root.expressions.at(0)
32
35
 
33
- assert_equal( true, exp.include?('a') )
34
- assert_equal( true, exp.include?('c-e') )
35
- assert_equal( true, exp.include?('h') )
36
- assert_equal( false, exp.include?(']') )
36
+ assert_equal true, exp.include?('a')
37
+ assert_equal true, exp.include?('c-e')
38
+ assert_equal true, exp.include?('h')
39
+ assert_equal false, exp.include?(']')
37
40
  end
38
41
 
39
42
  def test_parse_chat_type_set_members
40
- exp = RP.parse('[\da-z]', :any)[0]
43
+ root = RP.parse('[\da-z]', :any)
44
+ exp = root.expressions.at(0)
41
45
 
42
- assert_equal( true, exp.include?('\d') )
43
- assert_equal( true, exp.include?('a-z') )
46
+ assert_equal true, exp.include?('\d')
47
+ assert_equal true, exp.include?('a-z')
44
48
  end
45
49
 
46
50
  def test_parse_set_collating_sequence
47
- exp = RP.parse('[a[.span-ll.]h]', :any)[0]
51
+ root = RP.parse('[a[.span-ll.]h]', :any)
52
+ exp = root.expressions.at(0)
48
53
 
49
- assert_equal( true, exp.include?('[.span-ll.]') )
50
- assert_equal( false, exp.include?(']') )
54
+ assert_equal true, exp.include?('[.span-ll.]')
55
+ assert_equal false, exp.include?(']')
51
56
  end
52
57
 
53
58
  def test_parse_set_character_equivalents
54
- exp = RP.parse('[a[=e=]h]', :any)[0]
59
+ root = RP.parse('[a[=e=]h]', :any)
60
+ exp = root.expressions.at(0)
55
61
 
56
- assert_equal( true, exp.include?('[=e=]') )
57
- assert_equal( false, exp.include?(']') )
62
+ assert_equal true, exp.include?('[=e=]')
63
+ assert_equal false, exp.include?(']')
58
64
  end
59
65
 
60
66
  def test_parse_set_nesting_tos
61
67
  pattern = '[a[b[^c]]]'
68
+ root = RP.parse(pattern, 'ruby/1.9')
62
69
 
63
- assert_equal( pattern, RP.parse(pattern, 'ruby/1.9').to_s )
70
+ assert_equal pattern, root.to_s
64
71
  end
65
72
 
66
73
  def test_parse_set_nesting_include
67
- exp = RP.parse('[a[b[^c]]]', 'ruby/1.9')[0]
74
+ root = RP.parse('[a[b[^c]]]', 'ruby/1.9')
75
+ exp = root.expressions.at(0)
68
76
 
69
- assert_equal( true, exp.is_a?(CharacterSet) )
70
- assert_equal( true, exp.include?('a') )
71
- assert_equal( true, exp.include?('b') )
72
- assert_equal( true, exp.include?('c') )
77
+ assert_equal true, exp.is_a?(CharacterSet)
78
+ assert_equal true, exp.include?('a')
79
+ assert_equal true, exp.include?('b')
80
+ assert_equal true, exp.include?('c')
73
81
  end
74
82
 
75
83
  def test_parse_set_nesting_include_at_depth
76
- exp = RP.parse('[a[b]c]', 'ruby/1.9')[0]
77
-
78
- assert_equal( true, exp.is_a?(CharacterSet) )
79
- assert_equal( true, exp.include?('a') )
80
- assert_equal( true, exp.include?('b') )
81
- assert_equal( false, exp.include?('b', true) ) # should not include b directly
82
-
83
- sub = exp.members[1]
84
- assert_equal( false, sub.include?('a') )
85
- assert_equal( true, sub.include?('b') )
86
- assert_equal( true, sub.include?('b', true) )
87
- assert_equal( false, sub.include?('c') )
84
+ root = RP.parse('[a[b]c]', 'ruby/1.9')
85
+
86
+ exp = root.expressions.at(0)
87
+ assert_equal true, exp.is_a?(CharacterSet)
88
+ assert_equal true, exp.include?('a')
89
+ assert_equal true, exp.include?('b')
90
+ assert_equal false, exp.include?('b', true) # should not include b directly
91
+
92
+ sub = exp.members.at(1)
93
+ assert_equal false, sub.include?('a')
94
+ assert_equal true, sub.include?('b')
95
+ assert_equal true, sub.include?('b', true)
96
+ assert_equal false, sub.include?('c')
88
97
  end
89
98
 
90
99
  def test_parse_set_nesting_include_at_depth_2
91
- exp = RP.parse('[a[b[c[d]e]f]g]', 'ruby/1.9')[0]
92
-
93
- assert_equal( true, exp.is_a?(CharacterSet) )
94
- assert_equal( true, exp.include?('a') )
95
- assert_equal( true, exp.include?('b') )
96
- assert_equal( false, exp.include?('b', true) ) # should not include b directly
97
-
98
- sub = exp.members[1]
99
- assert_equal( false, sub.include?('a') )
100
- assert_equal( true, sub.include?('b') )
101
- assert_equal( true, sub.include?('b', true) )
102
- assert_equal( true, sub.include?('f', true) )
103
- assert_equal( true, sub.include?('c') )
104
- assert_equal( false, sub.include?('c', true) )
105
-
106
- sub2 = sub.members[1]
107
- assert_equal( false, sub2.include?('a') )
108
- assert_equal( false, sub2.include?('b') )
109
- assert_equal( true, sub2.include?('c') )
110
- assert_equal( true, sub2.include?('c', true) )
111
- assert_equal( true, sub2.include?('e', true) )
112
- assert_equal( true, sub2.include?('d') )
113
- assert_equal( false, sub2.include?('d', true) )
114
-
115
- sub3 = sub2.members[1]
116
- assert_equal( false, sub3.include?('a') )
117
- assert_equal( false, sub3.include?('g') )
118
- assert_equal( false, sub3.include?('b') )
119
- assert_equal( false, sub3.include?('f') )
120
- assert_equal( false, sub3.include?('c') )
121
- assert_equal( false, sub3.include?('e') )
122
- assert_equal( true, sub3.include?('d') )
123
- assert_equal( true, sub3.include?('d', true) )
100
+ root = RP.parse('[a[b[c[d]e]f]g]', 'ruby/1.9')
101
+
102
+ exp = root.expressions.at(0)
103
+ assert_equal true, exp.is_a?(CharacterSet)
104
+ assert_equal true, exp.include?('a')
105
+ assert_equal true, exp.include?('b')
106
+ assert_equal false, exp.include?('b', true) # should not include b directly
107
+
108
+ sub = exp.members.at(1)
109
+ assert_equal false, sub.include?('a')
110
+ assert_equal true, sub.include?('b')
111
+ assert_equal true, sub.include?('b', true)
112
+ assert_equal true, sub.include?('f', true)
113
+ assert_equal true, sub.include?('c')
114
+ assert_equal false, sub.include?('c', true)
115
+
116
+ sub2 = sub.members.at(1)
117
+ assert_equal false, sub2.include?('a')
118
+ assert_equal false, sub2.include?('b')
119
+ assert_equal true, sub2.include?('c')
120
+ assert_equal true, sub2.include?('c', true)
121
+ assert_equal true, sub2.include?('e', true)
122
+ assert_equal true, sub2.include?('d')
123
+ assert_equal false, sub2.include?('d', true)
124
+
125
+ sub3 = sub2.members.at(1)
126
+ assert_equal false, sub3.include?('a')
127
+ assert_equal false, sub3.include?('g')
128
+ assert_equal false, sub3.include?('b')
129
+ assert_equal false, sub3.include?('f')
130
+ assert_equal false, sub3.include?('c')
131
+ assert_equal false, sub3.include?('e')
132
+ assert_equal true, sub3.include?('d')
133
+ assert_equal true, sub3.include?('d', true)
124
134
  end
125
135
 
126
136
  # character subsets and negated posix classes are not available in ruby 1.8
127
137
  if RUBY_VERSION >= '1.9'
128
138
  def test_parse_set_nesting_matches
129
- exp = RP.parse('[a[b[^c]]]', 'ruby/1.9')[0]
139
+ root = RP.parse('[a[b[^c]]]', 'ruby/1.9')
140
+ exp = root.expressions.at(0)
130
141
 
131
- assert_equal( true, exp.matches?("b") )
132
- assert_equal( false, exp.matches?("c") )
142
+ assert_equal true, exp.matches?('b')
143
+ assert_equal false, exp.matches?('c')
133
144
  end
134
145
 
135
146
  def test_parse_set_nesting_not_matches
136
- exp = RP.parse('[a[b[^c]]]', 'ruby/1.9')[0]
137
- assert_equal( false, exp.matches?("c") )
147
+ root = RP.parse('[a[b[^c]]]', 'ruby/1.9')
148
+ exp = root.expressions.at(0)
149
+
150
+ assert_equal false, exp.matches?('c')
138
151
  end
139
152
 
140
153
  def test_parse_set_negated_posix_class
141
- exp = RP.parse('[[:^xdigit:][:^lower:]]+', 'ruby/1.9').expressions[0]
154
+ root = RP.parse('[[:^xdigit:][:^lower:]]+', 'ruby/1.9')
155
+ exp = root.expressions.at(0)
142
156
 
143
- assert_equal( true, exp.is_a?(CharacterSet) )
157
+ assert_equal true, exp.is_a?(CharacterSet)
144
158
 
145
- assert_equal( true, exp.include?('[:^xdigit:]') )
146
- assert_equal( true, exp.include?('[:^lower:]') )
159
+ assert_equal true, exp.include?('[:^xdigit:]')
160
+ assert_equal true, exp.include?('[:^lower:]')
147
161
 
148
- assert_equal( true, exp.matches?("GT") )
162
+ assert_equal true, exp.matches?('GT')
149
163
  end
150
164
  end
151
165
 
@@ -16,17 +16,16 @@ class TestParserTypes < Test::Unit::TestCase
16
16
  /a\Wc/ => [1, :type, :nonword, CharacterType::NonWord],
17
17
  }
18
18
 
19
- count = 0
20
- tests.each do |pattern, test|
21
- define_method "test_parse_type_#{test[2]}_#{count+=1}" do
19
+ tests.each_with_index do |(pattern, (index, type, token, klass)), count|
20
+ define_method "test_parse_type_#{token}_#{count}" do
22
21
  root = RP.parse(pattern, 'ruby/1.9')
23
- exp = root.expressions[test[0]]
22
+ exp = root.expressions.at(index)
24
23
 
25
- assert( exp.is_a?( test[3] ),
26
- "Expected #{test[3]}, but got #{exp.class.name}")
24
+ assert exp.is_a?( klass ),
25
+ "Expected #{klass}, but got #{exp.class.name}"
27
26
 
28
- assert_equal( test[1], exp.type )
29
- assert_equal( test[2], exp.token )
27
+ assert_equal type, exp.type
28
+ assert_equal token, exp.token
30
29
  end
31
30
  end
32
31
 
@@ -16,21 +16,23 @@ end
16
16
  class TestRegexpScanner < Test::Unit::TestCase
17
17
 
18
18
  def test_scanner_returns_an_array
19
- assert_instance_of( Array, RS.scan('abc') )
19
+ assert_instance_of Array, RS.scan('abc')
20
20
  end
21
21
 
22
22
  def test_scanner_returns_tokens_as_arrays
23
23
  tokens = RS.scan('^abc+[^one]{2,3}\b\d\\\C-C$')
24
24
 
25
- assert( tokens.all?{|token|
25
+ all_arrays = tokens.all? do |token|
26
26
  token.kind_of?(Array) and token.length == 5
27
- }, "Not all tokens are arrays of 5 elements")
27
+ end
28
+
29
+ assert all_arrays, 'Not all tokens are arrays of 5 elements'
28
30
  end
29
31
 
30
32
  def test_scanner_token_count
31
33
  re = /^(one|two){2,3}([^d\]efm-qz\,\-]*)(ghi)+$/i
32
34
 
33
- assert_equal(26, RS.scan(re).length )
35
+ assert_equal 26, RS.scan(re).length
34
36
  end
35
37
 
36
38
  end