Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

67 lines (52 sloc) 1.199 kB
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.first.name)
match = grammar2.parse('b')
assert(match)
assert_equal(:b, match.first.name)
end
def test_to_s
rule = Super.new
assert_equal('super', rule.to_s)
end
end
Jump to Line
Something went wrong with that request. Please try again.