diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-17 13:28:46 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-03-17 13:28:46 +0000 |
commit | 89afc5431b10e20689bcaac33a9e81a12d1b2b95 (patch) | |
tree | fcff3a675f88b5e65a8fcac6884866943dfe1b7e /test/ruby/test_array.rb | |
parent | c97735b53c8b1c9f76543c9d802dde097b0f4e7a (diff) | |
download | ruby-89afc5431b10e20689bcaac33a9e81a12d1b2b95.tar.gz |
* 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
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 16 |
1 files changed, 16 insertions, 0 deletions
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 |