Sha256: 1a87d082572291fcb217608c5a7b12b22d7cce4a6c30ffa2a4c95583c644a2e0

Contents?: true

Size: 1.39 KB

Versions: 86

Compression:

Stored size: 1.39 KB

Contents

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

class StringTerminalTest < Test::Unit::TestCase
  def test_terminal?
    rule = StringTerminal.new
    assert(rule.terminal?)
  end

  def test_eql?
    rule = StringTerminal.new('abc')
    assert_equal('abc', rule)
  end

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

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

  def test_exec_short
    rule = StringTerminal.new('abc')
    events = rule.exec(Input.new('ab'))
    assert_equal([], events)
  end

  def test_exec_long
    rule = StringTerminal.new('abc')
    events = rule.exec(Input.new('abcd'))
    assert_equal([rule, CLOSE, 3], events)
  end

  def test_exec_case_insensitive
    rule = StringTerminal.new('abc', Regexp::IGNORECASE)

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

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

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

  def test_to_s
    rule = StringTerminal.new('abc')
    assert_equal('"abc"', rule.to_s)
  end

  def test_to_s_case_insensitive
    rule = StringTerminal.new('abc', Regexp::IGNORECASE)
    assert_equal('`abc`', rule.to_s)
  end
end

Version data entries

86 entries across 86 versions & 2 rubygems

Version Path
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/string_terminal_test.rb