Sha256: 499ee43541104164fe8a1632342c803836a01d2ce385d78c5b4dd61b6a77147f

Contents?: true

Size: 970 Bytes

Versions: 86

Compression:

Stored size: 970 Bytes

Contents

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

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

  def test_exec
    rule = AndPredicate.new('abc')
    events = rule.exec(Input.new('abc'))
    assert_equal([rule, CLOSE, 0], events)
  end

  def test_exec_miss
    rule = AndPredicate.new('def')
    events = rule.exec(Input.new('abc'))
    assert_equal([], events)
  end

  def test_consumption
    rule = AndPredicate.new(Sequence.new(['a', 'b', 'c']))

    input = Input.new('abc')
    events = rule.exec(input)
    assert_equal(0, input.pos)

    input = Input.new('def')
    events = rule.exec(input)
    assert_equal(0, input.pos)
  end

  def test_to_s
    rule = AndPredicate.new('a')
    assert_equal('&"a"', rule.to_s)
  end

  def test_to_s_with_label
    rule = AndPredicate.new('a')
    rule.label = 'a_label'
    assert_equal('a_label:&"a"', rule.to_s)
  end
end

Version data entries

86 entries across 86 versions & 2 rubygems

Version Path
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.79 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.78 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.77 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.76 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.75 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.74 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb
harbr-0.1.71 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/and_predicate_test.rb