regexp_parser 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -1
  3. data/Gemfile +1 -1
  4. data/README.md +9 -13
  5. data/lib/regexp_parser/expression.rb +33 -21
  6. data/lib/regexp_parser/expression/classes/backref.rb +18 -10
  7. data/lib/regexp_parser/expression/classes/conditional.rb +4 -0
  8. data/lib/regexp_parser/expression/classes/group.rb +4 -2
  9. data/lib/regexp_parser/expression/classes/keep.rb +1 -3
  10. data/lib/regexp_parser/expression/methods/match_length.rb +172 -0
  11. data/lib/regexp_parser/expression/quantifier.rb +2 -2
  12. data/lib/regexp_parser/expression/sequence.rb +0 -4
  13. data/lib/regexp_parser/expression/subexpression.rb +3 -5
  14. data/lib/regexp_parser/lexer.rb +31 -24
  15. data/lib/regexp_parser/parser.rb +25 -3
  16. data/lib/regexp_parser/syntax/tokens.rb +2 -10
  17. data/lib/regexp_parser/version.rb +1 -1
  18. data/regexp_parser.gemspec +2 -2
  19. data/spec/expression/base_spec.rb +80 -0
  20. data/spec/expression/clone_spec.rb +120 -0
  21. data/spec/expression/conditional_spec.rb +89 -0
  22. data/spec/expression/free_space_spec.rb +27 -0
  23. data/spec/expression/methods/match_length_spec.rb +141 -0
  24. data/spec/expression/methods/strfregexp_spec.rb +224 -0
  25. data/spec/expression/methods/tests_spec.rb +97 -0
  26. data/spec/expression/methods/traverse_spec.rb +140 -0
  27. data/spec/expression/subexpression_spec.rb +50 -0
  28. data/spec/expression/to_h_spec.rb +26 -0
  29. data/spec/expression/to_s_spec.rb +100 -0
  30. data/spec/lexer/all_spec.rb +22 -0
  31. data/{test/lexer/test_conditionals.rb → spec/lexer/conditionals_spec.rb} +31 -35
  32. data/spec/lexer/escapes_spec.rb +38 -0
  33. data/spec/lexer/keep_spec.rb +22 -0
  34. data/{test/lexer/test_literals.rb → spec/lexer/literals_spec.rb} +20 -24
  35. data/{test/lexer/test_nesting.rb → spec/lexer/nesting_spec.rb} +11 -13
  36. data/spec/lexer/refcalls_spec.rb +54 -0
  37. data/spec/parser/all_spec.rb +31 -0
  38. data/spec/parser/alternation_spec.rb +88 -0
  39. data/{test/parser/test_anchors.rb → spec/parser/anchors_spec.rb} +7 -10
  40. data/spec/parser/conditionals_spec.rb +179 -0
  41. data/spec/parser/errors_spec.rb +51 -0
  42. data/spec/parser/escapes_spec.rb +132 -0
  43. data/spec/parser/free_space_spec.rb +130 -0
  44. data/spec/parser/groups_spec.rb +267 -0
  45. data/spec/parser/keep_spec.rb +19 -0
  46. data/spec/parser/posix_classes_spec.rb +27 -0
  47. data/spec/parser/properties_spec.rb +127 -0
  48. data/spec/parser/quantifiers_spec.rb +293 -0
  49. data/spec/parser/refcalls_spec.rb +237 -0
  50. data/spec/parser/set/intersections_spec.rb +127 -0
  51. data/spec/parser/set/ranges_spec.rb +111 -0
  52. data/spec/parser/sets_spec.rb +178 -0
  53. data/{test/parser/test_types.rb → spec/parser/types_spec.rb} +13 -20
  54. data/spec/scanner/all_spec.rb +18 -0
  55. data/{test/scanner/test_anchors.rb → spec/scanner/anchors_spec.rb} +8 -10
  56. data/{test/scanner/test_conditionals.rb → spec/scanner/conditionals_spec.rb} +49 -53
  57. data/spec/scanner/errors_spec.rb +90 -0
  58. data/{test/scanner/test_escapes.rb → spec/scanner/escapes_spec.rb} +8 -10
  59. data/{test/scanner/test_free_space.rb → spec/scanner/free_space_spec.rb} +48 -52
  60. data/{test/scanner/test_groups.rb → spec/scanner/groups_spec.rb} +33 -41
  61. data/spec/scanner/keep_spec.rb +33 -0
  62. data/{test/scanner/test_literals.rb → spec/scanner/literals_spec.rb} +8 -12
  63. data/{test/scanner/test_meta.rb → spec/scanner/meta_spec.rb} +8 -10
  64. data/{test/scanner/test_properties.rb → spec/scanner/properties_spec.rb} +14 -19
  65. data/{test/scanner/test_quantifiers.rb → spec/scanner/quantifiers_spec.rb} +7 -9
  66. data/{test/scanner/test_refcalls.rb → spec/scanner/refcalls_spec.rb} +9 -9
  67. data/{test/scanner/test_scripts.rb → spec/scanner/scripts_spec.rb} +8 -12
  68. data/{test/scanner/test_sets.rb → spec/scanner/sets_spec.rb} +14 -17
  69. data/spec/scanner/types_spec.rb +29 -0
  70. data/spec/scanner/unicode_blocks_spec.rb +28 -0
  71. data/spec/spec_helper.rb +14 -0
  72. data/{test → spec}/support/runner.rb +9 -8
  73. data/{test → spec}/support/warning_extractor.rb +5 -7
  74. data/spec/syntax/syntax_spec.rb +44 -0
  75. data/spec/syntax/syntax_token_map_spec.rb +23 -0
  76. data/spec/syntax/versions/1.8.6_spec.rb +38 -0
  77. data/spec/syntax/versions/1.9.1_spec.rb +23 -0
  78. data/spec/syntax/versions/1.9.3_spec.rb +22 -0
  79. data/spec/syntax/versions/2.0.0_spec.rb +28 -0
  80. data/spec/syntax/versions/2.2.0_spec.rb +22 -0
  81. data/spec/syntax/versions/aliases_spec.rb +119 -0
  82. data/spec/token/token_spec.rb +85 -0
  83. metadata +131 -140
  84. data/test/expression/test_all.rb +0 -12
  85. data/test/expression/test_base.rb +0 -90
  86. data/test/expression/test_clone.rb +0 -89
  87. data/test/expression/test_conditionals.rb +0 -113
  88. data/test/expression/test_free_space.rb +0 -35
  89. data/test/expression/test_set.rb +0 -84
  90. data/test/expression/test_strfregexp.rb +0 -230
  91. data/test/expression/test_subexpression.rb +0 -58
  92. data/test/expression/test_tests.rb +0 -99
  93. data/test/expression/test_to_h.rb +0 -59
  94. data/test/expression/test_to_s.rb +0 -104
  95. data/test/expression/test_traverse.rb +0 -161
  96. data/test/helpers.rb +0 -10
  97. data/test/lexer/test_all.rb +0 -41
  98. data/test/lexer/test_keep.rb +0 -24
  99. data/test/lexer/test_refcalls.rb +0 -56
  100. data/test/parser/set/test_intersections.rb +0 -127
  101. data/test/parser/set/test_ranges.rb +0 -111
  102. data/test/parser/test_all.rb +0 -64
  103. data/test/parser/test_alternation.rb +0 -92
  104. data/test/parser/test_conditionals.rb +0 -187
  105. data/test/parser/test_errors.rb +0 -63
  106. data/test/parser/test_escapes.rb +0 -134
  107. data/test/parser/test_free_space.rb +0 -139
  108. data/test/parser/test_groups.rb +0 -289
  109. data/test/parser/test_keep.rb +0 -21
  110. data/test/parser/test_posix_classes.rb +0 -27
  111. data/test/parser/test_properties.rb +0 -134
  112. data/test/parser/test_quantifiers.rb +0 -301
  113. data/test/parser/test_refcalls.rb +0 -186
  114. data/test/parser/test_sets.rb +0 -179
  115. data/test/scanner/test_all.rb +0 -38
  116. data/test/scanner/test_errors.rb +0 -91
  117. data/test/scanner/test_keep.rb +0 -35
  118. data/test/scanner/test_types.rb +0 -35
  119. data/test/scanner/test_unicode_blocks.rb +0 -30
  120. data/test/support/disable_autotest.rb +0 -8
  121. data/test/syntax/test_all.rb +0 -6
  122. data/test/syntax/test_syntax.rb +0 -61
  123. data/test/syntax/test_syntax_token_map.rb +0 -25
  124. data/test/syntax/versions/test_1.8.rb +0 -55
  125. data/test/syntax/versions/test_1.9.1.rb +0 -36
  126. data/test/syntax/versions/test_1.9.3.rb +0 -32
  127. data/test/syntax/versions/test_2.0.0.rb +0 -37
  128. data/test/syntax/versions/test_2.2.0.rb +0 -32
  129. data/test/syntax/versions/test_aliases.rb +0 -129
  130. data/test/syntax/versions/test_all.rb +0 -5
  131. data/test/test_all.rb +0 -5
  132. data/test/token/test_all.rb +0 -2
  133. data/test/token/test_token.rb +0 -107
@@ -1,179 +0,0 @@
1
- require File.expand_path("../../helpers", __FILE__)
2
-
3
- class TestParserSets < Test::Unit::TestCase
4
- def test_parse_set_basic
5
- root = RP.parse('[ab]+')
6
- exp = root[0]
7
-
8
- assert_equal CharacterSet, exp.class
9
- assert_equal 2, exp.count
10
-
11
- assert_equal Literal, exp[0].class
12
- assert_equal 'a', exp[0].text
13
- assert_equal Literal, exp[1].class
14
- assert_equal 'b', exp[1].text
15
-
16
- assert exp.quantified?
17
- assert_equal 1, exp.quantifier.min
18
- assert_equal(-1, exp.quantifier.max)
19
- end
20
-
21
- def test_parse_set_char_type
22
- root = RP.parse('[a\dc]')
23
- exp = root[0]
24
-
25
- assert_equal CharacterSet, exp.class
26
- assert_equal 3, exp.count
27
-
28
- assert_equal CharacterType::Digit, exp[1].class
29
- assert_equal '\d', exp[1].text
30
- end
31
-
32
- def test_parse_set_escape_sequence_backspace
33
- root = RP.parse('[a\bc]')
34
- exp = root[0]
35
-
36
- assert_equal CharacterSet, exp.class
37
- assert_equal 3, exp.count
38
-
39
- assert_equal EscapeSequence::Backspace, exp[1].class
40
- assert_equal '\b', exp[1].text
41
-
42
- assert exp.matches?('a')
43
- assert exp.matches?("\b")
44
- refute exp.matches?('b')
45
- assert exp.matches?('c')
46
- end
47
-
48
- def test_parse_set_escape_sequence_hex
49
- root = RP.parse('[a\x20c]', :any)
50
- exp = root[0]
51
-
52
- assert_equal CharacterSet, exp.class
53
- assert_equal 3, exp.count
54
-
55
- assert_equal EscapeSequence::Hex, exp[1].class
56
- assert_equal '\x20', exp[1].text
57
- end
58
-
59
- def test_parse_set_escape_sequence_codepoint
60
- root = RP.parse('[a\u0640]')
61
- exp = root[0]
62
-
63
- assert_equal CharacterSet, exp.class
64
- assert_equal 2, exp.count
65
-
66
- assert_equal EscapeSequence::Codepoint, exp[1].class
67
- assert_equal '\u0640', exp[1].text
68
- end
69
-
70
- def test_parse_set_escape_sequence_codepoint_list
71
- root = RP.parse('[a\u{41 1F60D}]')
72
- exp = root[0]
73
-
74
- assert_equal CharacterSet, exp.class
75
- assert_equal 2, exp.count
76
-
77
- assert_equal EscapeSequence::CodepointList, exp[1].class
78
- assert_equal '\u{41 1F60D}', exp[1].text
79
- end
80
-
81
- def test_parse_set_posix_class
82
- root = RP.parse('[[:digit:][:^lower:]]+')
83
- exp = root[0]
84
-
85
- assert_equal CharacterSet, exp.class
86
- assert_equal 2, exp.count
87
-
88
- assert_equal PosixClass, exp[0].class
89
- assert_equal '[:digit:]', exp[0].text
90
- assert_equal PosixClass, exp[1].class
91
- assert_equal '[:^lower:]', exp[1].text
92
- end
93
-
94
- def test_parse_set_nesting
95
- root = RP.parse('[a[b[c]d]e]')
96
-
97
- exp = root[0]
98
- assert_equal CharacterSet, exp.class
99
- assert_equal 3, exp.count
100
- assert_equal Literal, exp[0].class
101
- assert_equal Literal, exp[2].class
102
-
103
- subset1 = exp[1]
104
- assert_equal CharacterSet, subset1.class
105
- assert_equal 3, subset1.count
106
- assert_equal Literal, subset1[0].class
107
- assert_equal Literal, subset1[2].class
108
-
109
- subset2 = subset1[1]
110
- assert_equal CharacterSet, subset2.class
111
- assert_equal 1, subset2.count
112
- assert_equal Literal, subset2[0].class
113
- end
114
-
115
- def test_parse_set_nesting_negative
116
- root = RP.parse('[a[^b[c]]]')
117
- exp = root[0]
118
-
119
- assert_equal CharacterSet, exp.class
120
- assert_equal 2, exp.count
121
- assert_equal Literal, exp[0].class
122
- refute exp.negative?
123
-
124
- subset1 = exp[1]
125
- assert_equal CharacterSet, subset1.class
126
- assert_equal 2, subset1.count
127
- assert_equal Literal, subset1[0].class
128
- assert subset1.negative?
129
-
130
- subset2 = subset1[1]
131
- assert_equal CharacterSet, subset2.class
132
- assert_equal 1, subset2.count
133
- assert_equal Literal, subset2[0].class
134
- refute subset2.negative?
135
- end
136
-
137
- def test_parse_set_nesting_to_s
138
- pattern = '[a[b[^c]]]'
139
- root = RP.parse(pattern)
140
-
141
- assert_equal pattern, root.to_s
142
- end
143
-
144
- def test_parse_set_literals_are_not_merged
145
- root = RP.parse("[#{'a' * 10}]")
146
- exp = root[0]
147
-
148
- assert_equal 10, exp.count
149
- end
150
-
151
- def test_parse_set_whitespace_is_not_merged
152
- root = RP.parse("[#{' ' * 10}]")
153
- exp = root[0]
154
-
155
- assert_equal 10, exp.count
156
- end
157
-
158
- def test_parse_set_whitespace_is_not_merged_in_x_mode
159
- root = RP.parse("(?x)[#{' ' * 10}]")
160
- exp = root[1]
161
-
162
- assert_equal 10, exp.count
163
- end
164
-
165
- # TODO: Collations and equivalents need own exp class if they ever get enabled
166
- def test_parse_set_collating_sequence
167
- root = RP.parse('[a[.span-ll.]h]', :any)
168
- exp = root[0]
169
-
170
- assert_equal '[.span-ll.]', exp[1].to_s
171
- end
172
-
173
- def test_parse_set_character_equivalents
174
- root = RP.parse('[a[=e=]h]', :any)
175
- exp = root[0]
176
-
177
- assert_equal '[=e=]', exp[1].to_s
178
- end
179
- end
@@ -1,38 +0,0 @@
1
- require File.expand_path("../../helpers", __FILE__)
2
-
3
- %w[
4
- anchors errors escapes free_space groups literals meta
5
- properties quantifiers refcalls scripts sets types unicode_blocks
6
- ].each do |tc|
7
- require File.expand_path("../test_#{tc}", __FILE__)
8
- end
9
-
10
- if RUBY_VERSION >= '2.0.0'
11
- %w{conditionals keep}.each do|tc|
12
- require File.expand_path("../test_#{tc}", __FILE__)
13
- end
14
- end
15
-
16
- class TestRegexpScanner < Test::Unit::TestCase
17
-
18
- def test_scanner_returns_an_array
19
- assert_instance_of Array, RS.scan('abc')
20
- end
21
-
22
- def test_scanner_returns_tokens_as_arrays
23
- tokens = RS.scan('^abc+[^one]{2,3}\b\d\\\C-C$')
24
-
25
- all_arrays = tokens.all? do |token|
26
- token.kind_of?(Array) and token.length == 5
27
- end
28
-
29
- assert all_arrays, 'Not all tokens are arrays of 5 elements'
30
- end
31
-
32
- def test_scanner_token_count
33
- re = /^(one|two){2,3}([^d\]efm-qz\,\-]*)(ghi)+$/i
34
-
35
- assert_equal 28, RS.scan(re).length
36
- end
37
-
38
- end
@@ -1,91 +0,0 @@
1
- require File.expand_path("../../helpers", __FILE__)
2
-
3
- class ScannerErrors < Test::Unit::TestCase
4
-
5
- def test_scanner_unbalanced_set
6
- assert_raise( RS::PrematureEndError ) { RS.scan('[[:alpha:]') }
7
- end
8
-
9
- def test_scanner_unbalanced_group
10
- assert_raise( RS::PrematureEndError ) { RS.scan('(abc') }
11
- end
12
-
13
- def test_scanner_unbalanced_interval
14
- assert_raise( RS::PrematureEndError ) { RS.scan('a{1,2') }
15
- end
16
-
17
- def test_scanner_eof_in_property
18
- assert_raise( RS::PrematureEndError ) { RS.scan('\p{asci') }
19
- end
20
-
21
- def test_scanner_incomplete_property
22
- assert_raise( RS::PrematureEndError ) { RS.scan('\p{ascii abc') }
23
- end
24
-
25
- def test_scanner_unknown_property
26
- assert_raise( RS::UnknownUnicodePropertyError ) { RS.scan('\p{foobar}') }
27
- end
28
-
29
- def test_scanner_incomplete_options
30
- assert_raise( RS::ScannerError ) { RS.scan('(?mix abc)') }
31
- end
32
-
33
- def test_scanner_eof_options
34
- assert_raise( RS::PrematureEndError ) { RS.scan('(?mix') }
35
- end
36
-
37
- def test_scanner_incorrect_options
38
- assert_raise( RS::ScannerError ) { RS.scan('(?mix^bc') }
39
- end
40
-
41
- def test_scanner_eof_escape
42
- assert_raise( RS::PrematureEndError ) { RS.scan('\\') }
43
- end
44
-
45
- def test_scanner_eof_in_hex_escape
46
- assert_raise( RS::PrematureEndError ) { RS.scan('\x') }
47
- end
48
-
49
- def test_scanner_eof_in_codepoint_escape
50
- assert_raise( RS::PrematureEndError ) { RS.scan('\u') }
51
- assert_raise( RS::PrematureEndError ) { RS.scan('\u0') }
52
- assert_raise( RS::PrematureEndError ) { RS.scan('\u00') }
53
- assert_raise( RS::PrematureEndError ) { RS.scan('\u000') }
54
- assert_raise( RS::PrematureEndError ) { RS.scan('\u{') }
55
- assert_raise( RS::PrematureEndError ) { RS.scan('\u{00') }
56
- assert_raise( RS::PrematureEndError ) { RS.scan('\u{0000') }
57
- assert_raise( RS::PrematureEndError ) { RS.scan('\u{0000 ') }
58
- assert_raise( RS::PrematureEndError ) { RS.scan('\u{0000 0000') }
59
- end
60
-
61
- def test_scanner_eof_in_control_sequence
62
- assert_raise( RS::PrematureEndError ) { RS.scan('\c') }
63
- assert_raise( RS::PrematureEndError ) { RS.scan('\c\M') }
64
- assert_raise( RS::PrematureEndError ) { RS.scan('\c\M-') }
65
- assert_raise( RS::PrematureEndError ) { RS.scan('\C') }
66
- assert_raise( RS::PrematureEndError ) { RS.scan('\C-') }
67
- assert_raise( RS::PrematureEndError ) { RS.scan('\C-\M') }
68
- assert_raise( RS::PrematureEndError ) { RS.scan('\C-\M-') }
69
- end
70
-
71
- def test_scanner_eof_in_meta_sequence
72
- assert_raise( RS::PrematureEndError ) { RS.scan('\M') }
73
- assert_raise( RS::PrematureEndError ) { RS.scan('\M-') }
74
- assert_raise( RS::PrematureEndError ) { RS.scan('\M-\\') }
75
- assert_raise( RS::PrematureEndError ) { RS.scan('\M-\c') }
76
- assert_raise( RS::PrematureEndError ) { RS.scan('\M-\C') }
77
- assert_raise( RS::PrematureEndError ) { RS.scan('\M-\C-') }
78
- end
79
-
80
- def test_scanner_invalid_hex_escape
81
- assert_raise( RS::InvalidSequenceError ) { RS.scan('\xZ') }
82
- assert_raise( RS::InvalidSequenceError ) { RS.scan('\xZ0') }
83
- end
84
-
85
- def test_scanner_invalid_named_group
86
- assert_raise( RS::InvalidGroupError ) { RS.scan("(?'')") }
87
- assert_raise( RS::InvalidGroupError ) { RS.scan("(?''empty-name)") }
88
- assert_raise( RS::InvalidGroupError ) { RS.scan("(?<>)") }
89
- assert_raise( RS::InvalidGroupError ) { RS.scan("(?<>empty-name)") }
90
- end
91
- end
@@ -1,35 +0,0 @@
1
- require File.expand_path("../../helpers", __FILE__)
2
-
3
- class ScannerKeep < Test::Unit::TestCase
4
-
5
- def test_scan_keep_token
6
- tokens = RS.scan(/ab\Kcd/)
7
- result = tokens.at(1)
8
-
9
- assert_equal :keep, result[0]
10
- assert_equal :mark, result[1]
11
- assert_equal '\\K', result[2]
12
- assert_equal 2, result[3]
13
- assert_equal 4, result[4]
14
- end
15
-
16
- def test_scan_keep_nested
17
- tokens = RS.scan(/(a\Kb)|(c\\\Kd)ef/)
18
-
19
- first = tokens.at(2)
20
- second = tokens.at(9)
21
-
22
- assert_equal :keep, first[0]
23
- assert_equal :mark, first[1]
24
- assert_equal '\\K', first[2]
25
- assert_equal 2, first[3]
26
- assert_equal 4, first[4]
27
-
28
- assert_equal :keep, second[0]
29
- assert_equal :mark, second[1]
30
- assert_equal '\\K', second[2]
31
- assert_equal 11, second[3]
32
- assert_equal 13, second[4]
33
- end
34
-
35
- end
@@ -1,35 +0,0 @@
1
- require File.expand_path("../../helpers", __FILE__)
2
-
3
- class ScannerTypes < Test::Unit::TestCase
4
-
5
- tests = {
6
- 'a\dc' => [1, :type, :digit, '\d', 1, 3],
7
- 'a\Dc' => [1, :type, :nondigit, '\D', 1, 3],
8
-
9
- 'a\hc' => [1, :type, :hex, '\h', 1, 3],
10
- 'a\Hc' => [1, :type, :nonhex, '\H', 1, 3],
11
-
12
- 'a\sc' => [1, :type, :space, '\s', 1, 3],
13
- 'a\Sc' => [1, :type, :nonspace, '\S', 1, 3],
14
-
15
- 'a\wc' => [1, :type, :word, '\w', 1, 3],
16
- 'a\Wc' => [1, :type, :nonword, '\W', 1, 3],
17
-
18
- 'a\Rc' => [1, :type, :linebreak, '\R', 1, 3],
19
- 'a\Xc' => [1, :type, :xgrapheme, '\X', 1, 3],
20
- }
21
-
22
- tests.each do |(pattern, (index, type, token, text, ts, te))|
23
- define_method "test_scanner_#{type}_#{token}" do
24
- tokens = RS.scan(pattern)
25
- result = tokens.at(index)
26
-
27
- assert_equal type, result[0]
28
- assert_equal token, result[1]
29
- assert_equal text, result[2]
30
- assert_equal ts, result[3]
31
- assert_equal te, result[4]
32
- end
33
- end
34
-
35
- end
@@ -1,30 +0,0 @@
1
- require File.expand_path("../../helpers", __FILE__)
2
-
3
- class ScannerUnicodeBlocks < Test::Unit::TestCase
4
-
5
- tests = {
6
- 'InArabic' => :in_arabic,
7
- 'InCJK_Unified_Ideographs_Extension_A' => :in_cjk_unified_ideographs_extension_a,
8
- 'In Letterlike Symbols' => :in_letterlike_symbols,
9
- 'InMiscellaneous_Mathematical_Symbols-A' => :in_miscellaneous_mathematical_symbols_a,
10
- }
11
-
12
- tests.each_with_index do |(property, token), count|
13
- define_method "test_scanner_property_#{token}_#{count}" do
14
- tokens = RS.scan("a\\p{#{property}}c")
15
- result = tokens.at(1)
16
-
17
- assert_equal :property, result[0]
18
- assert_equal token, result[1]
19
- end
20
-
21
- define_method "test_scanner_nonproperty_#{token}_#{count}" do
22
- tokens = RS.scan("a\\P{#{property}}c")
23
- result = tokens.at(1)
24
-
25
- assert_equal :nonproperty, result[0]
26
- assert_equal token, result[1]
27
- end
28
- end
29
-
30
- end
@@ -1,8 +0,0 @@
1
- require 'test/unit/autorunner'
2
-
3
- module Test::Unit
4
- class AutoRunner
5
- def self.need_auto_run?
6
- end
7
- end
8
- end
@@ -1,6 +0,0 @@
1
- require File.expand_path("../../helpers", __FILE__)
2
-
3
- require File.expand_path("../test_syntax", __FILE__)
4
- require File.expand_path("../versions/test_all", __FILE__)
5
-
6
- require File.expand_path("../test_syntax_token_map", __FILE__)
@@ -1,61 +0,0 @@
1
- require File.expand_path("../../helpers", __FILE__)
2
-
3
- class TestSyntax < Test::Unit::TestCase
4
-
5
- def test_syntax_unknown_name
6
- assert_raise( Regexp::Syntax::UnknownSyntaxNameError ) {
7
- Regexp::Syntax.new('ruby/1.0')
8
- }
9
- end
10
-
11
- def test_syntax_new
12
- assert_instance_of Regexp::Syntax::V1_9_3,
13
- Regexp::Syntax.new('ruby/1.9.3')
14
- end
15
-
16
- def test_syntax_new_any
17
- assert_instance_of Regexp::Syntax::Any,
18
- Regexp::Syntax.new('any')
19
- assert_instance_of Regexp::Syntax::Any,
20
- Regexp::Syntax.new('*')
21
- end
22
-
23
- def test_syntax_not_implemented
24
- assert_raise( Regexp::Syntax::NotImplementedError ) {
25
- RP.parse('\p{alpha}', 'ruby/1.8')
26
- }
27
- end
28
-
29
- def test_syntax_supported?
30
- assert_equal false, Regexp::Syntax.supported?('ruby/1.1.1')
31
- assert_equal true, Regexp::Syntax.supported?('ruby/2.4.3')
32
- assert_equal true, Regexp::Syntax.supported?('ruby/2.5')
33
- end
34
-
35
- def test_syntax_invalid_version
36
- assert_raise( Regexp::Syntax::InvalidVersionNameError ) {
37
- Regexp::Syntax.version_class('2.0.0')
38
- }
39
-
40
- assert_raise( Regexp::Syntax::InvalidVersionNameError ) {
41
- Regexp::Syntax.version_class('ruby/20')
42
- }
43
- end
44
-
45
- def test_syntax_version_class_tiny_version
46
- assert_equal Regexp::Syntax::V1_9_3,
47
- Regexp::Syntax.version_class('ruby/1.9.3')
48
-
49
- assert_equal Regexp::Syntax::V2_3_1,
50
- Regexp::Syntax.version_class('ruby/2.3.1')
51
- end
52
-
53
- def test_syntax_version_class_minor_version
54
- assert_equal Regexp::Syntax::V1_9,
55
- Regexp::Syntax.version_class('ruby/1.9')
56
-
57
- assert_equal Regexp::Syntax::V2_3,
58
- Regexp::Syntax.version_class('ruby/2.3')
59
- end
60
-
61
- end