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-0.1.90 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.79 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.78 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.77 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.76 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.75 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.74 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb
harbr-0.1.71 vendor/bundle/ruby/3.2.0/gems/citrus-3.0.2/test/extension_test.rb