Sha256: d8949367d90b26dcce2144d8baff59246c8c4455ba80d0cffdfaf3e31269835b

Contents?: true

Size: 716 Bytes

Versions: 110

Compression:

Stored size: 716 Bytes

Contents

require 'test_helper'
require 'tins/xt'

module Tins
  class PartialApplicationTest < Test::Unit::TestCase

    def mul(x, y) x * y end

    define_method(:dup) { |y| method(:mul).partial(2)[y] }

    define_method(:trip) { |y| method(:mul).partial(3)[y] }


    def test_proc
      mul   = lambda { |x, y| x * y }
      klon  = mul.partial
      dup   = mul.partial(2)
      trip  = mul.partial(3)
      assert_equal [ 6, 9, 12 ], [ dup[3], trip[3], mul[4, 3] ]
      assert_equal [ 6, 9, 12 ], [ dup[3], trip[3], klon[4, 3] ]
      assert_raises(ArgumentError) do
        mul.partial(1, 2, 3)
      end
    end

    def test_method
      assert_equal [ 6, 9, 12 ], [ dup(3), trip(3), mul(4, 3) ]
    end
  end
end

Version data entries

110 entries across 105 versions & 9 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/tests/partial_application_test.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/tests/partial_application_test.rb
tdiary-5.0.11 vendor/bundle/gems/tins-1.16.3/tests/partial_application_test.rb
tdiary-5.0.9 vendor/bundle/gems/tins-1.16.3/tests/partial_application_test.rb
tdiary-5.0.8 vendor/bundle/gems/tins-0.13.2/tests/partial_application_test.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/tins-1.16.3/tests/partial_application_test.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/tins-0.13.2/tests/partial_application_test.rb
tdiary-5.0.7 vendor/bundle/gems/tins-1.16.3/tests/partial_application_test.rb
tins-1.16.3 tests/partial_application_test.rb
tins-1.16.2 tests/partial_application_test.rb
tins-1.16.1 tests/partial_application_test.rb
tins-1.16.0 tests/partial_application_test.rb
tins-1.15.1 tests/partial_application_test.rb
tdiary-5.0.6 vendor/bundle/gems/tins-1.15.0/tests/partial_application_test.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/tins-1.6.0/tests/partial_application_test.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/tests/partial_application_test.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/tests/partial_application_test.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/tests/partial_application_test.rb
tins-1.15.0 tests/partial_application_test.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/tins-1.13.2/tests/partial_application_test.rb