From 99a268a89df5e61cea9abecc8ed37432d82e9c42 Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Fri, 16 Dec 2011 12:45:22 +0100 Subject: [PATCH] more tests --- test/functional_test.rb | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/test/functional_test.rb b/test/functional_test.rb index 20aa11e..9497c66 100644 --- a/test/functional_test.rb +++ b/test/functional_test.rb @@ -2,13 +2,28 @@ require 'test/unit' require 'functional' class FunTest < Test::Unit::TestCase + M = 0..100 + + def doit_fun m, &exe + f = m.to_fun + yield f + f.to_a + end + def test_to_fun_exists assert_respond_to Object, :to_fun end - def test_to_fun_to_a - assert_equal (0..100).to_a, (0..100).to_fun.to_a + def test_to_a + assert_equal M.to_a, doit_fun( M) {|x| x } end - + def test_collect + l = lambda {|x| x*2} + assert_equal M.collect( &l), doit_fun( M) {|x| x.collect( &l) } + end + + def test_inject + assert_equal M.inject( 0) {|i,j| i+j }, M.to_fun.inject( 0) {|i,j| i+j } + end end