Sha256: 7c5493b34e4a8623874b3fe0d16ab1758814dde80fbaad5f0623302c719eccbc
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
require File.dirname(__FILE__) + '/helper' Citrus.load(File.dirname(__FILE__) + '/_files/super') class SuperTest < Test::Unit::TestCase def test_terminal? rule = Super.new assert_equal(false, rule.terminal?) end def test_match grammar1 = Grammar.new { rule :a, 'a' } grammar2 = Grammar.new { include grammar1 rule :a, any('b', sup) } match = grammar2.parse('b') assert(match) assert('b', match.text) assert(1, match.length) match = grammar2.parse('a') assert(match) assert('a', match.text) assert(1, match.length) end def test_peg match = SuperTwo.parse('2') assert(match) match = SuperTwo.parse('1') assert(match) end def test_nested grammar1 = Grammar.new { rule :a, 'a' rule :b, 'b' } grammar2 = Grammar.new { include grammar1 rule :a, any(sup, :b) rule :b, sup } match = grammar2.parse('a') assert(match) assert_equal(:a, match.name) match = grammar2.parse('b') assert(match) assert_equal(:b, match.name) end def test_to_s rule = Super.new assert_equal('super', rule.to_s) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
citrus-1.4.0 | test/super_test.rb |
citrus-1.3.0 | test/super_test.rb |