Sha256: a41537ed7d22d13c6470987771507253dda5af0432d9eea499ad318b41bce874

Contents?: true

Size: 1.54 KB

Versions: 12

Compression:

Stored size: 1.54 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))

module Racc
  class TestChkY < TestCase
    def setup
      file = File.join(ASSET_DIR, 'chk.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_chk_y
      generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)

      # it generates valid ruby
      assert Module.new {
        self.instance_eval(generator.generate_parser, __FILE__, __LINE__)
      }

      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_chk_y_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.instance_eval(generator.generate_parser, __FILE__, __LINE__)
      }

      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

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
racc-1.4.15-java test/test_chk_y.rb
racc-1.4.15 test/test_chk_y.rb
racc-1.4.14-java test/test_chk_y.rb
racc-1.4.14 test/test_chk_y.rb
racc-1.4.13-java test/test_chk_y.rb
racc-1.4.13 test/test_chk_y.rb
racc-1.4.12-java test/test_chk_y.rb
racc-1.4.12 test/test_chk_y.rb
racc-1.4.11 test/test_chk_y.rb
gd-racc-1.4.11 test/test_chk_y.rb
racc-1.4.10 test/test_chk_y.rb
racc-1.4.9-java test/test_chk_y.rb