Sha256: 179848cdb22bfd1adcd846681df825bddf22794f4556015e36d04624db4a82a7

Contents?: true

Size: 848 Bytes

Versions: 74

Compression:

Stored size: 848 Bytes

Contents

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

class ExtensionTest < Test::Unit::TestCase
  module MatchModule
    def a_test
      :test
    end
  end

  module NumericModule
    def add_one
      to_str.to_i + 1
    end
  end

  NumericProcBare = Proc.new {
    to_str.to_i + 1
  }

  def test_match_module
    rule = StringTerminal.new('abc')
    rule.extension = MatchModule
    match = rule.parse('abc')
    assert(match)
    assert_equal(:test, match.a_test)
  end

  def test_numeric_module
    rule = StringTerminal.new('1')
    rule.extension = NumericModule
    match = rule.parse('1')
    assert(match)
    assert_equal(2, match.add_one)
  end

  def test_numeric_proc_bare
    rule = StringTerminal.new('1')
    rule.extension = NumericProcBare
    match = rule.parse('1')
    assert(match)
    assert_equal(2, match.value)
  end
end

Version data entries

74 entries across 74 versions & 2 rubygems

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