Sha256: e735a5df7a399bbd4a6f1d601032b78a2ab7894489a82c0743431ef87bd4401d

Contents?: true

Size: 1.08 KB

Versions: 76

Compression:

Stored size: 1.08 KB

Contents

require File.expand_path('../helper', __FILE__)

class AliasTest < Test::Unit::TestCase
  def test_terminal?
    rule = Alias.new
    assert_equal(false, rule.terminal?)
  end

  def test_exec
    grammar = Grammar.new {
      rule :a, :b
      rule :b, 'abc'
    }
    rule_a = grammar.rule(:a)
    events = rule_a.exec(Input.new('abc'))
    assert_equal([rule_a, CLOSE, 3], events)
  end

  def test_exec_miss
    grammar = Grammar.new {
      rule :a, :b
      rule :b, 'abc'
    }
    rule = grammar.rule(:a)
    events = rule.exec(Input.new('def'))
    assert_equal([], events)
  end

  def test_exec_included
    grammar1 = Grammar.new {
      rule :a, 'abc'
    }
    grammar2 = Grammar.new {
      include grammar1
      rule :b, :a
    }
    rule_b2 = grammar2.rule(:b)
    events = rule_b2.exec(Input.new('abc'))
    assert_equal([rule_b2, CLOSE, 3], events)
  end

  def test_to_s
    rule = Alias.new(:alpha)
    assert_equal('alpha', rule.to_s)
  end

  def test_to_s_with_label
    rule = Alias.new(:alpha)
    rule.label = 'a_label'
    assert_equal('a_label:alpha', rule.to_s)
  end
end

Version data entries

76 entries across 76 versions & 2 rubygems

Version Path
harbr-0.1.49 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.48 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.47 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.39 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.38 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
harbr-0.1.37 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/alias_test.rb
citrus-3.0.2 test/alias_test.rb
citrus-3.0.1 test/alias_test.rb
citrus-3.0.0 test/alias_test.rb
citrus-2.5.0 test/alias_test.rb