Sha256: f0e373f72e88d04fb5d1f8c02a04611e1c07b81389e4c49bc789fe6a9e2656ab

Contents?: true

Size: 974 Bytes

Versions: 1

Compression:

Stored size: 974 Bytes

Contents

require 'function/composite'

using Function::Composite

class Function::CompositeTest < Test::Unit::TestCase
  def test_that_it_has_a_version_number
    assert_not_nil ::Function::Composite::VERSION
  end

  def test_symbol_to_symbol
    result = %w{72 101 108 108 111}.map(&:to_i >> :chr)
    assert_equal(["H", "e", "l", "l", "o"], result)
  end

  def test_symbol_from_symbol
    result = %w{72 101 108 108 111}.map(&:chr << :to_i)
    assert_equal(["H", "e", "l", "l", "o"], result)
  end

  def test_proc_to_symbol
    result = %w{72 101 108 108 111}.map(&proc {|s| s.to_i} >> :chr)
    assert_equal(["H", "e", "l", "l", "o"], result)
  end

  def test_symbol_from_proc
    result = %w{72 101 108 108 111}.map(&:chr << proc {|s| s.to_i})
    assert_equal(["H", "e", "l", "l", "o"], result)
  end

  def test_symbol_to_callable
    h = {Alice: 30, Bob: 60, Cris: 90}
    result = %w{Alice Bob Cris}.map(&(:to_sym >> h))
    assert_equal([30, 60, 90], result)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
function-composite-0.1.0 test/test-function-composite.rb