regexp_parser 0.4.13 → 0.5.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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +15 -0
  3. data/lib/regexp_parser/expression.rb +43 -51
  4. data/lib/regexp_parser/expression/classes/alternation.rb +6 -7
  5. data/lib/regexp_parser/expression/classes/character_class.rb +11 -0
  6. data/lib/regexp_parser/expression/classes/conditional.rb +10 -18
  7. data/lib/regexp_parser/expression/classes/free_space.rb +1 -1
  8. data/lib/regexp_parser/expression/classes/group.rb +9 -21
  9. data/lib/regexp_parser/expression/classes/property.rb +2 -2
  10. data/lib/regexp_parser/expression/classes/set.rb +1 -12
  11. data/lib/regexp_parser/expression/methods/traverse.rb +1 -1
  12. data/lib/regexp_parser/expression/quantifier.rb +9 -9
  13. data/lib/regexp_parser/expression/sequence.rb +5 -4
  14. data/lib/regexp_parser/expression/subexpression.rb +16 -59
  15. data/lib/regexp_parser/lexer.rb +31 -27
  16. data/lib/regexp_parser/parser.rb +179 -179
  17. data/lib/regexp_parser/scanner.rb +172 -166
  18. data/lib/regexp_parser/scanner/scanner.rl +44 -38
  19. data/lib/regexp_parser/syntax.rb +2 -53
  20. data/lib/regexp_parser/syntax/base.rb +13 -24
  21. data/lib/regexp_parser/syntax/tokens/character_class.rb +16 -0
  22. data/lib/regexp_parser/syntax/tokens/unicode_property.rb +26 -26
  23. data/lib/regexp_parser/syntax/version_lookup.rb +82 -0
  24. data/lib/regexp_parser/syntax/versions.rb +1 -5
  25. data/lib/regexp_parser/syntax/versions/1.8.6.rb +30 -0
  26. data/lib/regexp_parser/syntax/versions/1.9.1.rb +36 -0
  27. data/lib/regexp_parser/syntax/versions/1.9.3.rb +11 -0
  28. data/lib/regexp_parser/syntax/versions/2.0.0.rb +20 -0
  29. data/lib/regexp_parser/syntax/versions/2.2.0.rb +10 -0
  30. data/lib/regexp_parser/syntax/versions/2.3.0.rb +10 -0
  31. data/lib/regexp_parser/syntax/versions/2.4.0.rb +10 -0
  32. data/lib/regexp_parser/syntax/versions/2.4.1.rb +9 -0
  33. data/lib/regexp_parser/syntax/versions/2.5.0.rb +10 -0
  34. data/lib/regexp_parser/token.rb +6 -29
  35. data/lib/regexp_parser/version.rb +1 -1
  36. data/test/expression/test_strfregexp.rb +7 -0
  37. data/test/expression/test_to_h.rb +6 -0
  38. data/test/parser/test_properties.rb +12 -4
  39. data/test/support/warning_extractor.rb +3 -1
  40. data/test/syntax/test_all.rb +1 -1
  41. data/test/syntax/test_syntax.rb +5 -9
  42. data/test/syntax/{ruby → versions}/test_1.8.rb +14 -14
  43. data/test/syntax/{ruby → versions}/test_1.9.1.rb +7 -8
  44. data/test/syntax/{ruby → versions}/test_1.9.3.rb +7 -7
  45. data/test/syntax/versions/test_2.0.0.rb +37 -0
  46. data/test/syntax/{ruby → versions}/test_2.2.0.rb +7 -7
  47. data/test/syntax/versions/test_aliases.rb +129 -0
  48. data/test/syntax/{ruby → versions}/test_all.rb +1 -1
  49. metadata +73 -113
  50. data/lib/regexp_parser/syntax/ruby/1.8.6.rb +0 -37
  51. data/lib/regexp_parser/syntax/ruby/1.8.7.rb +0 -14
  52. data/lib/regexp_parser/syntax/ruby/1.8.rb +0 -13
  53. data/lib/regexp_parser/syntax/ruby/1.9.1.rb +0 -45
  54. data/lib/regexp_parser/syntax/ruby/1.9.2.rb +0 -9
  55. data/lib/regexp_parser/syntax/ruby/1.9.3.rb +0 -19
  56. data/lib/regexp_parser/syntax/ruby/1.9.rb +0 -8
  57. data/lib/regexp_parser/syntax/ruby/2.0.0.rb +0 -23
  58. data/lib/regexp_parser/syntax/ruby/2.0.rb +0 -8
  59. data/lib/regexp_parser/syntax/ruby/2.1.0.rb +0 -13
  60. data/lib/regexp_parser/syntax/ruby/2.1.10.rb +0 -13
  61. data/lib/regexp_parser/syntax/ruby/2.1.2.rb +0 -13
  62. data/lib/regexp_parser/syntax/ruby/2.1.3.rb +0 -13
  63. data/lib/regexp_parser/syntax/ruby/2.1.4.rb +0 -13
  64. data/lib/regexp_parser/syntax/ruby/2.1.5.rb +0 -13
  65. data/lib/regexp_parser/syntax/ruby/2.1.6.rb +0 -13
  66. data/lib/regexp_parser/syntax/ruby/2.1.7.rb +0 -13
  67. data/lib/regexp_parser/syntax/ruby/2.1.8.rb +0 -13
  68. data/lib/regexp_parser/syntax/ruby/2.1.9.rb +0 -13
  69. data/lib/regexp_parser/syntax/ruby/2.1.rb +0 -8
  70. data/lib/regexp_parser/syntax/ruby/2.2.0.rb +0 -16
  71. data/lib/regexp_parser/syntax/ruby/2.2.1.rb +0 -13
  72. data/lib/regexp_parser/syntax/ruby/2.2.10.rb +0 -13
  73. data/lib/regexp_parser/syntax/ruby/2.2.2.rb +0 -13
  74. data/lib/regexp_parser/syntax/ruby/2.2.3.rb +0 -13
  75. data/lib/regexp_parser/syntax/ruby/2.2.4.rb +0 -13
  76. data/lib/regexp_parser/syntax/ruby/2.2.5.rb +0 -13
  77. data/lib/regexp_parser/syntax/ruby/2.2.6.rb +0 -13
  78. data/lib/regexp_parser/syntax/ruby/2.2.7.rb +0 -13
  79. data/lib/regexp_parser/syntax/ruby/2.2.8.rb +0 -13
  80. data/lib/regexp_parser/syntax/ruby/2.2.9.rb +0 -13
  81. data/lib/regexp_parser/syntax/ruby/2.2.rb +0 -8
  82. data/lib/regexp_parser/syntax/ruby/2.3.0.rb +0 -16
  83. data/lib/regexp_parser/syntax/ruby/2.3.1.rb +0 -13
  84. data/lib/regexp_parser/syntax/ruby/2.3.2.rb +0 -13
  85. data/lib/regexp_parser/syntax/ruby/2.3.3.rb +0 -13
  86. data/lib/regexp_parser/syntax/ruby/2.3.4.rb +0 -13
  87. data/lib/regexp_parser/syntax/ruby/2.3.5.rb +0 -13
  88. data/lib/regexp_parser/syntax/ruby/2.3.6.rb +0 -13
  89. data/lib/regexp_parser/syntax/ruby/2.3.7.rb +0 -13
  90. data/lib/regexp_parser/syntax/ruby/2.3.rb +0 -8
  91. data/lib/regexp_parser/syntax/ruby/2.4.0.rb +0 -16
  92. data/lib/regexp_parser/syntax/ruby/2.4.1.rb +0 -15
  93. data/lib/regexp_parser/syntax/ruby/2.4.2.rb +0 -13
  94. data/lib/regexp_parser/syntax/ruby/2.4.3.rb +0 -13
  95. data/lib/regexp_parser/syntax/ruby/2.4.4.rb +0 -13
  96. data/lib/regexp_parser/syntax/ruby/2.4.rb +0 -8
  97. data/lib/regexp_parser/syntax/ruby/2.5.0.rb +0 -16
  98. data/lib/regexp_parser/syntax/ruby/2.5.1.rb +0 -13
  99. data/lib/regexp_parser/syntax/ruby/2.5.rb +0 -8
  100. data/lib/regexp_parser/syntax/ruby/2.6.0.rb +0 -13
  101. data/lib/regexp_parser/syntax/ruby/2.6.rb +0 -8
  102. data/test/syntax/ruby/test_2.0.0.rb +0 -32
  103. data/test/syntax/ruby/test_files.rb +0 -353
@@ -0,0 +1,82 @@
1
+ module Regexp::Syntax
2
+ VERSION_FORMAT = '\Aruby/\d+\.\d+(\.\d+)?\z'
3
+ VERSION_REGEXP = /#{VERSION_FORMAT}/
4
+ VERSION_CONST_REGEXP = /\AV\d+_\d+(?:_\d+)?\z/
5
+
6
+ class InvalidVersionNameError < SyntaxError
7
+ def initialize(name)
8
+ super "Invalid version name '#{name}'. Expected format is '#{VERSION_FORMAT}'"
9
+ end
10
+ end
11
+
12
+ class UnknownSyntaxNameError < SyntaxError
13
+ def initialize(name)
14
+ super "Unknown syntax name '#{name}'."
15
+ end
16
+ end
17
+
18
+ module_function
19
+
20
+ # Loads and instantiates an instance of the syntax specification class for
21
+ # the given syntax version name. The special names 'any' and '*' return an
22
+ # instance of Syntax::Any.
23
+ def new(name)
24
+ return Regexp::Syntax::Any.new if ['*', 'any'].include?(name.to_s)
25
+ version_class(name).new
26
+ end
27
+
28
+ def supported?(name)
29
+ name =~ VERSION_REGEXP &&
30
+ comparable_version(name) >= comparable_version('1.8.6')
31
+ end
32
+
33
+ def version_class(version)
34
+ version =~ VERSION_REGEXP || raise(InvalidVersionNameError, version)
35
+ version_const_name = version_const_name(version)
36
+ const_get(version_const_name) || raise(UnknownSyntaxNameError, version)
37
+ end
38
+
39
+ def version_const_name(version_string)
40
+ "V#{version_string.to_s.scan(/\d+/).join('_')}"
41
+ end
42
+
43
+ def const_missing(const_name)
44
+ if const_name =~ VERSION_CONST_REGEXP
45
+ return fallback_version_class(const_name)
46
+ end
47
+ super
48
+ end
49
+
50
+ def fallback_version_class(version)
51
+ sorted_versions = (specified_versions + [version])
52
+ .sort_by { |name| comparable_version(name) }
53
+ return if (version_index = sorted_versions.index(version)) < 1
54
+
55
+ next_lower_version = sorted_versions[version_index - 1]
56
+ inherit_from_version(next_lower_version, version)
57
+ end
58
+
59
+ def inherit_from_version(parent_version, new_version)
60
+ new_const = version_const_name(new_version)
61
+ parent = const_get(version_const_name(parent_version))
62
+ const_defined?(new_const) || const_set(new_const, Class.new(parent))
63
+ warn_if_future_version(new_const)
64
+ const_get(new_const)
65
+ end
66
+
67
+ def specified_versions
68
+ constants.select { |const_name| const_name =~ VERSION_CONST_REGEXP }
69
+ end
70
+
71
+ def comparable_version(name)
72
+ # add .99 to treat versions without a patch value as latest patch version
73
+ Gem::Version.new((name.to_s.scan(/\d+/) << 99).join('.'))
74
+ end
75
+
76
+ def warn_if_future_version(const_name)
77
+ return if comparable_version(const_name) < comparable_version('3.0.0')
78
+
79
+ warn('This library has only been tested up to Ruby 2.x, '\
80
+ "but you are running with #{const_get(const_name).inspect}")
81
+ end
82
+ end
@@ -3,8 +3,4 @@
3
3
  #
4
4
  # Aliases for the latest patch version are provided as 'ruby/n.n',
5
5
  # e.g. 'ruby/1.9' refers to Ruby v1.9.3.
6
- module Regexp::Syntax
7
- version_file_paths = Dir[File.expand_path('../ruby/*.rb', __FILE__)]
8
- version_file_paths.each { |path| require path }
9
- VERSIONS = version_file_paths.map { |path| path[%r{(ruby/[^/]+)\.rb}, 1] }
10
- end
6
+ Dir[File.expand_path('../versions/*.rb', __FILE__)].sort.each { |f| require f }
@@ -0,0 +1,30 @@
1
+ module Regexp::Syntax
2
+ class V1_8_6 < Regexp::Syntax::Base
3
+ def initialize
4
+ super
5
+
6
+ implements :anchor, Anchor::All
7
+ implements :assertion, Assertion::Lookahead
8
+ implements :backref, [:number]
9
+
10
+ implements :escape,
11
+ Escape::Basic + Escape::Backreference +
12
+ Escape::ASCII + Escape::Meta + Escape::Control
13
+
14
+ implements :group, Group::All
15
+
16
+ implements :meta, Meta::Extended
17
+
18
+ implements :quantifier,
19
+ Quantifier::Greedy + Quantifier::Reluctant +
20
+ Quantifier::Interval + Quantifier::IntervalReluctant
21
+
22
+ implements :set, CharacterSet::OpenClose +
23
+ CharacterSet::Extended + CharacterSet::Types +
24
+ CharacterSet::POSIX::Standard
25
+
26
+ implements :type,
27
+ CharacterType::Extended
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,36 @@
1
+ module Regexp::Syntax
2
+ class V1_9_1 < Regexp::Syntax::V1_8_6
3
+ def initialize
4
+ super
5
+
6
+ implements :assertion, Assertion::Lookbehind +
7
+ SubexpressionCall::All
8
+
9
+ implements :backref, Backreference::All +
10
+ SubexpressionCall::All
11
+
12
+ implements :escape, Escape::Unicode + Escape::Hex + Escape::Octal
13
+
14
+ implements :type, CharacterType::Hex
15
+
16
+ implements :property,
17
+ UnicodeProperty::V1_9_0
18
+
19
+ implements :nonproperty,
20
+ UnicodeProperty::V1_9_0
21
+
22
+ implements :quantifier,
23
+ Quantifier::Possessive + Quantifier::IntervalPossessive
24
+
25
+ implements :set,
26
+ CharacterSet::POSIX::StandardNegative +
27
+ CharacterSet::POSIX::Extensions +
28
+ CharacterSet::POSIX::ExtensionsNegative +
29
+ UnicodeProperty::V1_9_0
30
+
31
+ implements :subset, CharacterSet::OpenClose +
32
+ CharacterSet::Extended + CharacterSet::Types +
33
+ CharacterSet::POSIX::Standard
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ module Regexp::Syntax
2
+ class V1_9_3 < Regexp::Syntax::V1_9_1
3
+ def initialize
4
+ super
5
+
6
+ # these were added with update of Oniguruma to Unicode 6.0
7
+ implements :property, UnicodeProperty::V1_9_3
8
+ implements :nonproperty, UnicodeProperty::V1_9_3
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,20 @@
1
+ module Regexp::Syntax
2
+ # use the last 1.9 release as the base
3
+ class V2_0_0 < Regexp::Syntax::V1_9
4
+ def initialize
5
+ super
6
+
7
+ implements :keep, Keep::All
8
+ implements :conditional, Conditional::All
9
+ implements :property, UnicodeProperty::V2_0_0
10
+ implements :nonproperty, UnicodeProperty::V2_0_0
11
+
12
+ implements :type, CharacterType::Clustered
13
+ implements :set, CharacterSet::Clustered
14
+ implements :subset, CharacterSet::Clustered
15
+
16
+ excludes :property, :newline
17
+ excludes :nonproperty, :newline
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ module Regexp::Syntax
2
+ class V2_2_0 < Regexp::Syntax::V2_1
3
+ def initialize
4
+ super
5
+
6
+ implements :property, UnicodeProperty::V2_2_0
7
+ implements :nonproperty, UnicodeProperty::V2_2_0
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Regexp::Syntax
2
+ class V2_3_0 < Regexp::Syntax::V2_2
3
+ def initialize
4
+ super
5
+
6
+ implements :property, UnicodeProperty::V2_3_0
7
+ implements :nonproperty, UnicodeProperty::V2_3_0
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Regexp::Syntax
2
+ class V2_4_0 < Regexp::Syntax::V2_3
3
+ def initialize
4
+ super
5
+
6
+ implements :property, UnicodeProperty::V2_4_0
7
+ implements :nonproperty, UnicodeProperty::V2_4_0
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ module Regexp::Syntax
2
+ class V2_4_1 < Regexp::Syntax::V2_4_0
3
+ def initialize
4
+ super
5
+
6
+ implements :group, Group::Absence
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Regexp::Syntax
2
+ class V2_5_0 < Regexp::Syntax::V2_4
3
+ def initialize
4
+ super
5
+
6
+ implements :property, UnicodeProperty::V2_5_0
7
+ implements :nonproperty, UnicodeProperty::V2_5_0
8
+ end
9
+ end
10
+ end
@@ -12,45 +12,22 @@ class Regexp
12
12
  ].freeze
13
13
 
14
14
  Token = Struct.new(*TOKEN_KEYS) do
15
- def initialize(*)
16
- super
17
-
18
- @previous = @next = nil
19
- end
15
+ attr_accessor :previous, :next
20
16
 
21
17
  def offset
22
- [self.ts, self.te]
18
+ [ts, te]
23
19
  end
24
20
 
25
21
  def length
26
- self.te - self.ts
27
- end
28
-
29
- def next(exp = nil)
30
- if exp
31
- @next = exp
32
- else
33
- @next
34
- end
35
- end
36
-
37
- def previous(exp = nil)
38
- if exp
39
- @previous = exp
40
- else
41
- @previous
42
- end
22
+ te - ts
43
23
  end
44
24
 
45
25
  if RUBY_VERSION < '2.0.0'
46
26
  def to_h
47
- hash = {}
48
-
49
- members.each do |member|
50
- hash[member.to_sym] = self.send(member.to_sym)
27
+ members.inject({}) do |hash, member|
28
+ hash[member.to_sym] = self[member]
29
+ hash
51
30
  end
52
-
53
- hash
54
31
  end
55
32
  end
56
33
  end
@@ -1,5 +1,5 @@
1
1
  class Regexp
2
2
  class Parser
3
- VERSION = '0.4.13'
3
+ VERSION = '0.5.0'
4
4
  end
5
5
  end
@@ -167,6 +167,13 @@ class Expressionstrfregexp < Test::Unit::TestCase
167
167
  assert_equal root.strfregexp('%m %t'), root.strfregexp('%a')
168
168
  end
169
169
 
170
+ # regression test
171
+ def test_expression_strfregexp_conditional
172
+ root = RP.parse('(?<A>a)(?(<A>)b|c)', 'ruby/2.0')
173
+
174
+ assert_nothing_raised { root.strfregexp }
175
+ end
176
+
170
177
  def test_expression_strfregexp_tree
171
178
  root = RP.parse(/a[b-d]*(e(f+))?/)
172
179
 
@@ -50,4 +50,10 @@ class ExpressionToH < Test::Unit::TestCase
50
50
  }
51
51
  end
52
52
 
53
+ # regression test
54
+ def test_conditional_expression_to_h
55
+ root = RP.parse('(?<A>a)(?(<A>)b|c)', 'ruby/2.0')
56
+
57
+ assert_nothing_raised { root.to_h }
58
+ end
53
59
  end
@@ -20,8 +20,6 @@ class ParserProperties < Test::Unit::TestCase
20
20
  'Xdigit',
21
21
  'XPosixPunct',
22
22
 
23
- 'Newline',
24
-
25
23
  'Any',
26
24
  'Assigned',
27
25
 
@@ -368,14 +366,14 @@ class ParserProperties < Test::Unit::TestCase
368
366
  "Expected Script property, but got #{t.expressions[1].class.name}"
369
367
  end
370
368
 
371
- def test_parse_property_script_v193
369
+ def test_parse_property_script_V1_9_3
372
370
  t = RP.parse 'ab\p{Brahmi}cd', 'ruby/1.9.3'
373
371
 
374
372
  assert t.expressions[1].is_a?(UnicodeProperty::Script),
375
373
  "Expected Script property, but got #{t.expressions[1].class.name}"
376
374
  end
377
375
 
378
- def test_parse_property_script_v220
376
+ def test_parse_property_script_V2_2_0
379
377
  t = RP.parse 'ab\p{Caucasian_Albanian}cd', 'ruby/2.2'
380
378
 
381
379
  assert t.expressions[1].is_a?(UnicodeProperty::Script),
@@ -395,4 +393,14 @@ class ParserProperties < Test::Unit::TestCase
395
393
  assert t.expressions[2].is_a?(Literal),
396
394
  "Expected Literal, but got #{t.expressions[2].class.name}"
397
395
  end
396
+
397
+ def test_parse_abandoned_newline_property
398
+ t = RP.parse '\p{newline}', 'ruby/1.9'
399
+ assert t.expressions.last.is_a?(UnicodeProperty::Base),
400
+ "Expected property, but got #{t.expressions.last.class.name}"
401
+
402
+ assert_raise(Regexp::Syntax::NotImplementedError) {
403
+ RP.parse('\p{newline}', 'ruby/2.0')
404
+ }
405
+ end
398
406
  end
@@ -22,7 +22,9 @@ module RegexpParserTest
22
22
 
23
23
  yield
24
24
 
25
- assert_no_warnings($stderr.warnings)
25
+ if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.0.0')
26
+ assert_no_warnings($stderr.warnings)
27
+ end
26
28
  ensure
27
29
  $stderr = original
28
30
  end
@@ -1,4 +1,4 @@
1
1
  require File.expand_path("../../helpers", __FILE__)
2
2
 
3
3
  require File.expand_path("../test_syntax", __FILE__)
4
- require File.expand_path("../ruby/test_all", __FILE__)
4
+ require File.expand_path("../versions/test_all", __FILE__)
@@ -9,7 +9,7 @@ class TestSyntax < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  def test_syntax_new
12
- assert_instance_of Regexp::Syntax::Ruby::V193,
12
+ assert_instance_of Regexp::Syntax::V1_9_3,
13
13
  Regexp::Syntax.new('ruby/1.9.3')
14
14
  end
15
15
 
@@ -23,10 +23,6 @@ class TestSyntax < Test::Unit::TestCase
23
23
  assert_equal false, Regexp::Syntax.supported?('ruby/1.1.1')
24
24
  assert_equal true, Regexp::Syntax.supported?('ruby/2.4.3')
25
25
  assert_equal true, Regexp::Syntax.supported?('ruby/2.5')
26
-
27
- Regexp::Syntax::VERSIONS.each do |version|
28
- assert_equal true, Regexp::Syntax.supported?(version)
29
- end
30
26
  end
31
27
 
32
28
  def test_syntax_invalid_version
@@ -40,18 +36,18 @@ class TestSyntax < Test::Unit::TestCase
40
36
  end
41
37
 
42
38
  def test_syntax_version_class_tiny_version
43
- assert_equal Regexp::Syntax::Ruby::V193,
39
+ assert_equal Regexp::Syntax::V1_9_3,
44
40
  Regexp::Syntax.version_class('ruby/1.9.3')
45
41
 
46
- assert_equal Regexp::Syntax::Ruby::V231,
42
+ assert_equal Regexp::Syntax::V2_3_1,
47
43
  Regexp::Syntax.version_class('ruby/2.3.1')
48
44
  end
49
45
 
50
46
  def test_syntax_version_class_minor_version
51
- assert_equal Regexp::Syntax::Ruby::V19,
47
+ assert_equal Regexp::Syntax::V1_9,
52
48
  Regexp::Syntax.version_class('ruby/1.9')
53
49
 
54
- assert_equal Regexp::Syntax::Ruby::V23,
50
+ assert_equal Regexp::Syntax::V2_3,
55
51
  Regexp::Syntax.version_class('ruby/2.3')
56
52
  end
57
53
 
@@ -1,6 +1,6 @@
1
1
  require File.expand_path("../../../helpers", __FILE__)
2
2
 
3
- class TestSyntaxRuby_V18 < Test::Unit::TestCase
3
+ class TestSyntaxV1_8 < Test::Unit::TestCase
4
4
  include Regexp::Syntax::Token
5
5
 
6
6
  def setup
@@ -8,29 +8,29 @@ class TestSyntaxRuby_V18 < Test::Unit::TestCase
8
8
  end
9
9
 
10
10
  tests = {
11
- :implements => {
12
- :assertion => [Assertion::Lookahead].flatten,
13
- :backref => [:number],
14
- :escape => [Escape::All].flatten,
15
- :group => [Group::All].flatten,
16
- :quantifier => [
11
+ implements: {
12
+ assertion: [Assertion::Lookahead].flatten,
13
+ backref: [:number],
14
+ escape: [Escape::All].flatten,
15
+ group: [Group::All].flatten,
16
+ quantifier: [
17
17
  Quantifier::Greedy + Quantifier::Reluctant +
18
18
  Quantifier::Interval + Quantifier::IntervalReluctant
19
19
  ].flatten,
20
20
  },
21
21
 
22
- :excludes => {
23
- :assertion => [Assertion::Lookbehind].flatten,
22
+ excludes: {
23
+ assertion: [Assertion::Lookbehind].flatten,
24
24
 
25
- :backref => [
25
+ backref: [
26
26
  Backreference::All - [:number] + SubexpressionCall::All
27
27
  ].flatten,
28
28
 
29
- :quantifier => [
29
+ quantifier: [
30
30
  Quantifier::Possessive
31
31
  ].flatten,
32
32
 
33
- :subset => nil
33
+ subset: nil
34
34
  },
35
35
  }
36
36
 
@@ -39,12 +39,12 @@ class TestSyntaxRuby_V18 < Test::Unit::TestCase
39
39
 
40
40
  types.each do |type, tokens|
41
41
  if tokens.nil? or tokens.empty?
42
- define_method "test_syntax_ruby_v18_#{method}_#{type}" do
42
+ define_method "test_syntax_V1_8_#{method}_#{type}" do
43
43
  assert_equal expected, @syntax.implements?(type, nil)
44
44
  end
45
45
  else
46
46
  tokens.each do |token|
47
- define_method "test_syntax_ruby_v18_#{method}_#{type}_#{token}" do
47
+ define_method "test_syntax_V1_8_#{method}_#{type}_#{token}" do
48
48
  assert_equal expected, @syntax.implements?(type, token)
49
49
  end
50
50
  end