mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add extend testcase for #first, #last, #shift, #unshift, #pop, #push methods.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
07a45c21c0
commit
7a28fb146f
2 changed files with 33 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Jun 16 19:57:24 2004 Michal Rokos <michal@ruby-lang.org>
|
||||||
|
|
||||||
|
* test/ruby/test_array.rb: extend testcase to check #first, #last,
|
||||||
|
#shift, #unshift, #pop, #push
|
||||||
|
|
||||||
Wed Jun 16 16:05:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Jun 16 16:05:17 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (ary_new): move alloc behind checks. [ruby-core:02982]
|
* array.c (ary_new): move alloc behind checks. [ruby-core:02982]
|
||||||
|
|
|
@ -98,4 +98,32 @@ class TestArray < Test::Unit::TestCase
|
||||||
x.concat(x)
|
x.concat(x)
|
||||||
assert_equal([1,2,3,1,2,3], x)
|
assert_equal([1,2,3,1,2,3], x)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_beg_end
|
||||||
|
x = [1, 2, 3, 4, 5]
|
||||||
|
|
||||||
|
assert_equal(1, x.first)
|
||||||
|
assert_equal([1], x.first(1))
|
||||||
|
assert_equal([1, 2, 3], x.first(3))
|
||||||
|
|
||||||
|
assert_equal(5, x.last)
|
||||||
|
assert_equal([5], x.last(1))
|
||||||
|
assert_equal([3, 4, 5], x.last(3))
|
||||||
|
|
||||||
|
assert_equal(1, x.shift)
|
||||||
|
assert_equal([2, 3, 4], x.shift(3))
|
||||||
|
assert_equal([5], x)
|
||||||
|
|
||||||
|
assert_equal([2, 3, 4, 5], x.unshift(2, 3, 4))
|
||||||
|
assert_equal([1, 2, 3, 4, 5], x.unshift(1))
|
||||||
|
assert_equal([1, 2, 3, 4, 5], x)
|
||||||
|
|
||||||
|
assert_equal(5, x.pop)
|
||||||
|
assert_equal([3, 4], x.pop(2))
|
||||||
|
assert_equal([1, 2], x)
|
||||||
|
|
||||||
|
assert_equal([1, 2, 3, 4], x.push(3, 4))
|
||||||
|
assert_equal([1, 2, 3, 4, 5], x.push(5))
|
||||||
|
assert_equal([1, 2, 3, 4, 5], x)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue