1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/racc/test_scan_y.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.5 KiB
Ruby
Raw Normal View History

require File.expand_path(File.join(__dir__, 'case'))
2019-05-13 08:25:22 -04:00
module Racc
class TestScanY < TestCase
def setup
2019-07-02 01:10:50 -04:00
super
2019-05-13 08:25:22 -04:00
file = File.join(ASSET_DIR, 'scan.y')
@debug_flags = Racc::DebugFlags.parse_option_string('o')
parser = Racc::GrammarFileParser.new(@debug_flags)
@result = parser.parse(File.read(file), File.basename(file))
@states = Racc::States.new(@result.grammar).nfa
@states.dfa
end
def test_compile
generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
# it generates valid ruby
assert Module.new {
self.class_eval(generator.generate_parser)
}
grammar = @states.grammar
assert_equal 0, @states.n_srconflicts
assert_equal 0, @states.n_rrconflicts
assert_equal 0, grammar.n_useless_nonterminals
assert_equal 0, grammar.n_useless_rules
assert_nil grammar.n_expected_srconflicts
end
def test_compile_line_convert
params = @result.params.dup
params.convert_line_all = true
generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
# it generates valid ruby
assert Module.new {
self.class_eval(generator.generate_parser)
}
grammar = @states.grammar
assert_equal 0, @states.n_srconflicts
assert_equal 0, @states.n_rrconflicts
assert_equal 0, grammar.n_useless_nonterminals
assert_equal 0, grammar.n_useless_rules
assert_nil grammar.n_expected_srconflicts
end
end
end