Sha256: 47b1043cad054b9fc4e8a22ac819cd82113134eb9ea8dcc09e8c582589eb602c
Contents?: true
Size: 999 Bytes
Versions: 1
Compression:
Stored size: 999 Bytes
Contents
require 'test/unit' require 'rockit/dparser' class ATestSimpleGrammar < Test::Unit::TestCase SimpleTestGrammar = Rockit::DParser::Grammar.new do start :Str, [[:A, :B, :A, :C, ast(:Str, 0, 1, 3)]] term :A, ["a"] term :B, ["b"] term :C, ["c"] end def test_01_creation_of_grammar assert_kind_of(Rockit::DParser::Grammar, SimpleTestGrammar) assert_equal(1, SimpleTestGrammar.rules.length) assert_equal(3, SimpleTestGrammar.terms.values.length) assert_equal(:Str, SimpleTestGrammar.start_symbol) end def test_02_creation_of_parser parser = SimpleTestGrammar.new_parser assert_kind_of(Rockit::DParser::Parser, parser) end def test_03_use_parser parser = SimpleTestGrammar.new_parser ast = parser.parse "ab a\tc" assert_equal("Str", ast.name) assert_kind_of(parser.astclass_of_name(:Str), ast) assert_equal(3, ast.num_children) assert_equal("a", ast[0]) assert_equal("b", ast[1]) assert_equal("c", ast[2]) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rockit-0.7.1 | tests/acceptance/rockit/dparser/atest_simple_grammar.rb |