Sha256: 1f9a97e0c6de3c8ea06ac9235af2a0a2911aadd0c44329f298fa1659331608eb

Contents?: true

Size: 1.04 KB

Versions: 86

Compression:

Stored size: 1.04 KB

Contents

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

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

  def test_exec
    rule = ButPredicate.new('abc')

    events = rule.exec(Input.new('def'))
    assert_equal([rule, CLOSE, 3], events)

    events = rule.exec(Input.new('defabc'))
    assert_equal([rule, CLOSE, 3], events)
  end

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

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

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

    input = Input.new('defabc')
    events = rule.exec(input)
    assert_equal(3, input.pos)
  end

  def test_to_s
    rule = ButPredicate.new('a')
    assert_equal('~"a"', rule.to_s)
  end

  def test_to_s_with_label
    rule = ButPredicate.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.70 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.69 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.68 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.67 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.66 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.65 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.64 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.63 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.62 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.61 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.60 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.59 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.58 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.57 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.56 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.55 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.54 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.53 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.52 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb
harbr-0.1.50 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/but_predicate_test.rb