summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-17 13:28:46 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-17 13:28:46 +0000
commit966935629ba6c6d3bdeed4ad8d21af9f4ec2f2d9 (patch)
treefcff3a675f88b5e65a8fcac6884866943dfe1b7e /test/ruby/test_array.rb
parent1ab7c150f3bf25c2ddaaf5d2ab8ce422c80ff5d1 (diff)
downloadruby-966935629ba6c6d3bdeed4ad8d21af9f4ec2f2d9.tar.gz
ruby-966935629ba6c6d3bdeed4ad8d21af9f4ec2f2d9.tar.xz
ruby-966935629ba6c6d3bdeed4ad8d21af9f4ec2f2d9.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@15791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index c0206baed..ea2cef85c 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