Sha256: 21953b53302c6d63d25ad9e1c2de21d9c5c9c07c56b589b898c8851a3ff1dc34

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

require 'helper'
include Stages

class TestStages < MiniTest::Unit::TestCase
  
  test 'evens' do
    evens = Evens.new
    result = (0..2).map{ evens.run }
    assert_equal([0, 2, 4], result)
  end
    
  test 'select' do
    pipeline = Evens.new | Select.new{ |val| val > 6}
    result = (0..2).map{ |x| pipeline.run }
    assert_equal([8, 10, 12], result)
  end
  
  test 'map' do
    pipeline = Evens.new | Map.new{ |val| val * 3}
    result = (0..2).map{ |x| pipeline.run }
    assert_equal([0, 6, 12], result)
  end
  
  test 'multiples_of' do
    pipeline = Evens.new | MultiplesOf.new(3)
    result = (0..3).map{ |x| pipeline.run }
    assert_equal([0, 6, 12, 18], result)
  end
  
  test 'each_element' do
    pipeline = EachElement.new([1, 2, 3])
    result = (0..2).map{ |x| pipeline.run }
    assert_equal([1, 2, 3], result)
  end
  
  test 'hash_lookup' do
    pipeline = EachElement.new([:do, :re, :mi]) | HashLookup.new(sing)
    result = (0..2).map{ |x| pipeline.run }
    assert_equal(['doe a deer a female deer', 'ray a drop of golden sun', 'me a name I call myself'], result)
  end   
  
  def sing
    { :do => 'doe a deer a female deer',
      :re => 'ray a drop of golden sun',
      :mi => 'me a name I call myself',
      :fa => 'far a long long way to run',
      :so => 'A needle pulling thread',
      :la => 'a note to follow so',
      :ti => 'a drink with jam and bread'}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stages-0.0.1 test/test_stages.rb