Sha256: 7e6dd8e0f6d12a2448ee59a3fb029a680bd8600f75bf2527597061964ad3a1e4

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

require 'test/unit'
require 'rockit/dparser'

class ATestAnyOperator < Test::Unit::TestCase
  AnyTestGrammar = Rockit::DParser::Grammar.new do
    start :S, [["a", any("b", "c"), any(:D, :E), ast(:S, 0, 1, 2)]]
    ("d".."e").map {|s| term(s.upcase.intern, s)}
  end

  Parser = AnyTestGrammar.new_parser

  def test_01
    ast = Parser.parse "abd"
    assert_equal("a", ast[0])
    assert_equal("b", ast[1])
    assert_equal("d", ast[2])

    ast = Parser.parse "abe"
    assert_equal("a", ast[0])
    assert_equal("b", ast[1])
    assert_equal("e", ast[2])

    ast = Parser.parse "acd"
    assert_equal("a", ast[0])
    assert_equal("c", ast[1])
    assert_equal("d", ast[2])

    ast = Parser.parse "ace"
    assert_equal("a", ast[0])
    assert_equal("c", ast[1])
    assert_equal("e", 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_any_operator.rb