Sha256: b21eebde9666b654220d2fde617ad39fae431714785964c13a2d452fd7c0b64f

Contents?: true

Size: 847 Bytes

Versions: 9

Compression:

Stored size: 847 Bytes

Contents

  #  _____         _
  # |_   _|__  ___| |_
  #   | |/ _ \/ __| __|
  #   | |  __/\__ \ |
  #   |_|\___||___/\__|
  #
  # for lib/facets/functor.rb
  #
  # Extracted Mon Sep 03 16:23:07 -0700 2007
  # w/ Test Extraction Ratchet
  #

 require 'facets/functor.rb'



  require 'test/unit'

  class TC_Functor < Test::Unit::TestCase

    def test_function
      f = Functor.new { |op, x| x.send(op, x) }
      assert_equal( 2, f + 1 ) #=> 2
      assert_equal( 4, f + 2 ) #=> 4
      assert_equal( 6, f + 3 ) #=> 6
      assert_equal( 1, f * 1 ) #=> 1
      assert_equal( 4, f * 2 ) #=> 4
      assert_equal( 9, f * 3 ) #=> 9
    end

    def test_decoration
      a = 'A'
      f = Functor.new{ |op, x| x.send(op, a + x) }
      assert_equal( 'BAB', f + 'B' )
      assert_equal( 'CAC', f + 'C' )
      assert_equal( 'DAD', f + 'D' )
    end

  end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
facets-2.0.1 test/unit/test_functor.rb
facets-2.0.0 test/unit/test_functor.rb
facets-2.0.2 test/unit/test_functor.rb
facets-2.0.5 test/unit/test_functor.rb
facets-2.1.0 test/unit/test_functor.rb
facets-2.0.4 test/unit/test_functor.rb
facets-2.1.2 test/unit/test_functor.rb
facets-2.1.1 test/unit/test_functor.rb
facets-2.0.3 test/unit/test_functor.rb