Sha256: 0b267d98bed7d06cc16778426e2154ce035e255d44bf9b6c38f6a04886ed0f89

Contents?: true

Size: 1.29 KB

Versions: 25

Compression:

Stored size: 1.29 KB

Contents

#!/usr/local/bin/ruby -w

$TESTING = true

require 'composite_sexp_processor'
require 'test/unit'

class FakeProcessor1 < SexpProcessor # ZenTest SKIP

  def initialize
    super
    self.warn_on_default = false
    self.default_method = :default_processor
    self.expected = Array
  end

  def default_processor(exp)
    result = []
    until exp.empty? do
      result << exp.shift.to_s + " woot"
    end
    result
  end
end

class TestCompositeSexpProcessor < Test::Unit::TestCase

  def setup
    @p = CompositeSexpProcessor.new
  end

  def test_process_default
    data = [1, 2, 3]
    result = @p.process(data.dup)
    assert_equal(data.dup, result)
  end

  def test_process_fake1
    data = [1, 2, 3]
    @p << FakeProcessor1.new
    result = @p.process(data.dup)
    assert_equal(data.map {|x| "#{x} woot"}, result)
  end

  def test_process_fake1_twice
    data = [1, 2, 3]
    @p << FakeProcessor1.new
    @p << FakeProcessor1.new
    result = @p.process(data.dup)
    assert_equal(data.map {|x| "#{x} woot woot"}, result)
  end

  def test_processors
    # everything is tested by test_append
  end

  def test_append
    assert_equal([], @p.processors)

    assert_raises(ArgumentError) do
      @p << 42
    end

    fp1 = FakeProcessor1.new
    @p << fp1
    assert_equal([fp1], @p.processors)
  end

end

Version data entries

25 entries across 23 versions & 2 rubygems

Version Path
ParseTree-1.3.3 test/test_composite_sexp_processor.rb
ParseTree-1.2.0 test/test_composite_sexp_processor.rb
ParseTree-1.1.0 test_composite_sexp_processor.rb
ParseTree-1.3.6 test/test_composite_sexp_processor.rb
ParseTree-1.3.0 test/test_composite_sexp_processor.rb
ParseTree-1.3.5 test/test_composite_sexp_processor.rb
ParseTree-1.1.1 test_composite_sexp_processor.rb
ParseTree-1.3.4 test/test_composite_sexp_processor.rb
ParseTree-1.3.2 test/test_composite_sexp_processor.rb
ParseTree-1.6.1 test/test_composite_sexp_processor.rb
ParseTree-1.6.3 test/test_composite_sexp_processor.rb
ParseTree-1.6.2 test/test_composite_sexp_processor.rb
ParseTree-1.6.4 test/test_composite_sexp_processor.rb
ParseTree-1.4.0 test/test_composite_sexp_processor.rb
ParseTree-1.5.0 test/test_composite_sexp_processor.rb
ParseTree-1.6.0 test/test_composite_sexp_processor.rb
ParseTree-1.7.0 test/test_composite_sexp_processor.rb
ParseTree-1.4.1 test/test_composite_sexp_processor.rb
ParseTree-1.3.7 test/test_composite_sexp_processor.rb
ParseTree-2.0.0 test/test_composite_sexp_processor.rb