Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding tests for scan_y

  • Loading branch information...
commit e5d6abb45aa5c9d7611c075da92955f314778b04 1 parent d81148d
@tenderlove tenderlove authored
View
2  test/assets/scan.y
@@ -48,7 +48,7 @@ end
assert_equal 'some ', @pre_match
assert_equal 'regexp', @matched
assert_equal ' matches to this string', @post_match
- assert_instance_of MatchingData, @m
+ assert_instance_of MatchData, @m
end
def assert_equal(ok, data)
View
3  test/test_parserfilegenerator.rb → test/test_chk_y.rb
@@ -1,7 +1,7 @@
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
module Racc
- class TestParserFileGenerator < TestCase
+ class TestChkY < TestCase
def setup
file = File.join(ASSET_DIR, 'chk.y')
@debug_flags = Racc::DebugFlags.parse_option_string('o')
@@ -36,6 +36,7 @@ def test_compile_chk_y_line_convert
generator = Racc::ParserFileGenerator.new(@states, @result.params.dup)
fork { eval(generator.generate_parser) }
+ assert_equal 0, $?.exitstatus
Process.wait
grammar = @states.grammar
View
54 test/test_scan_y.rb
@@ -0,0 +1,54 @@
+require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
+
+module Racc
+ class TestChkY < TestCase
+ def setup
+ 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)
+
+ fork {
+ eval(generator.generate_parser)
+ }
+ File.open('/tmp/out.rb', 'wb') { |f|
+ f.write generator.generate_parser
+ }
+ Process.wait
+ assert_equal 0, $?.exitstatus
+
+ 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)
+
+ fork { eval(generator.generate_parser) }
+ assert_equal 0, $?.exitstatus
+ Process.wait
+
+ 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
Please sign in to comment.
Something went wrong with that request. Please try again.