From 89afc5431b10e20689bcaac33a9e81a12d1b2b95 Mon Sep 17 00:00:00 2001 From: mame Date: Mon, 17 Mar 2008 13:28:46 +0000 Subject: * array.c (rb_ary_take, rb_ary_take_while, rb_ary_drop, rb_ary_drop_while): new method. [ruby-dev:34067] * test/ruby/test_array.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_array.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index c0206baed5..ea2cef85cd 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1229,4 +1229,20 @@ class TestArray < Test::Unit::TestCase assert_equal(@cls[].permutation(0).to_a, @cls[[]]) end + + def test_take + assert_equal([1,2,3], [1,2,3,4,5,0].take(3)) + end + + def test_take_while + assert_equal([1,2], [1,2,3,4,5,0].take_while {|i| i < 3 }) + end + + def test_drop + assert_equal([4,5,0], [1,2,3,4,5,0].drop(3)) + end + + def test_drop_while + assert_equal([3,4,5,0], [1,2,3,4,5,0].drop_while {|i| i < 3 }) + end end -- cgit v1.2.3