require 'test/unit' require 'parse/expand_grammar' include Parse::Grammar class UT_Parse_expand_grammar < Test::Unit::TestCase def test_01_internal_nonterm_num g = Grammar.new assert_equal(1, g.next_free_internal_nonterminal_num) assert_equal(2, g.next_free_internal_nonterminal_num) assert_equal(3, g.next_free_internal_nonterminal_num) end def test_02_create_fresh_nonterminal g = Grammar.new nt = g.create_fresh_nonterminal assert_kind_of(NonTerminal, nt) # The name should start with the prefix re = Regexp.new("^" + Grammar::InternalNontermNamePrefix) assert_match(re, nt.name.to_s) end end