1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
mame 2008-03-17 13:28:46 +00:00
parent c97735b53c
commit 89afc5431b
3 changed files with 118 additions and 0 deletions

View file

@ -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