Sha256: 7e2a419ebb46237e6a79afe347b9c37d63b29ed11c5fbafdde29fcca57c4849f

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

require 'test/unit'

require 'parse/ebnf_grammar'
include Parse::Grammar

class UT_Parse_ebnf_grammar < Test::Unit::TestCase
  def test_01_Maybe_expansion
    g = Grammar.new do
      r :Start, [
        [maybe(:A), "1"]
      ]
      r :A, ["a"]
    end
    g.expand!
    assert_equal(3, g.nonterminals.length)
  end

  def test_02_Plus_expansion
    g = Grammar.new do
      r :Start, [
        [plus(:A), "1"]
      ]
      r :A, ["a"]
    end
    g.expand!
    assert_equal(4, g.nonterminals.length)
  end

  def test_03_Mult_expansion
    g = Grammar.new do
      r :Start, [
        [mult(:A), "1"]
      ]
      r :A, ["a"]
    end
    g.expand!
    assert_equal(3, g.nonterminals.length)
  end

  def test_04_Group_expansion
    g = Grammar.new do
      r :Start, [
        [group("1", "2"), "3"]
      ]
    end
    g.expand!
    puts g.inspect
    assert_equal(2, g.nonterminals.length)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rockit-0.7.1 tests/unit/parse/utest_ebnf_grammar.rb