Skip to content

Commit

Permalink
! Added tentative ruby 2.4 support. Probably missing things.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//src/ruby_parser/dev/": change = 11270]
  • Loading branch information
zenspider committed Mar 12, 2017
1 parent 356f235 commit 1814c37
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ lib/ruby22_parser.rb
lib/ruby22_parser.y
lib/ruby23_parser.rb
lib/ruby23_parser.y
lib/ruby24_parser.rb
lib/ruby24_parser.y
lib/ruby_lexer.rb
lib/ruby_lexer.rex
lib/ruby_lexer.rex.rb
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Hoe.add_include_dirs "../../minitest/dev/lib"
Hoe.add_include_dirs "../../oedipus_lex/dev/lib"

V1 = %w[18 19]
V2 = %w[20 21 22 23]
V2 = %w[20 21 22 23 24]
V1_2 = V1 + V2

Hoe.spec "ruby_parser" do
Expand Down
2 changes: 2 additions & 0 deletions lib/ruby_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ def self.for_current_ruby
require "ruby21_parser"
require "ruby22_parser"
require "ruby23_parser"
require "ruby24_parser"

class RubyParser # HACK
VERSIONS.clear # also a HACK caused by racc namespace issues

class V24 < ::Ruby24Parser; end
class V23 < ::Ruby23Parser; end
class V22 < ::Ruby22Parser; end
class V21 < ::Ruby21Parser; end
Expand Down
2 changes: 2 additions & 0 deletions lib/ruby_parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Ruby21Parser
class Ruby22Parser
#elif V == 23
class Ruby23Parser
#elif V == 24
class Ruby24Parser
#else
fail "version not specified or supported on code generation"
#endif
Expand Down
20 changes: 20 additions & 0 deletions test/test_ruby_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3385,6 +3385,10 @@ def test_slashy_newlines_within_string
end
end

module TestRubyParserShared24Plus
# ...version specific tests to go here...
end

class TestRubyParser < Minitest::Test
def test_cls_version
assert_equal 18, RubyParser::V18.version
Expand Down Expand Up @@ -3653,6 +3657,22 @@ def setup
end
end

class TestRubyParserV24 < RubyParserTestCase
include TestRubyParserShared
include TestRubyParserShared19Plus
include TestRubyParserShared20Plus
include TestRubyParserShared21Plus
include TestRubyParserShared22Plus
include TestRubyParserShared23Plus
include TestRubyParserShared24Plus

def setup
super

self.processor = RubyParser::V24.new
end
end

RubyParser::VERSIONS.each do |klass|
v = klass.version
describe "block args arity #{v}" do
Expand Down

0 comments on commit 1814c37

Please sign in to comment.