diff options
| author | michal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-16 11:01:15 +0000 |
|---|---|---|
| committer | michal <michal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-16 11:01:15 +0000 |
| commit | ccd46e878df5d1407ba24eb870327367e5705f8f (patch) | |
| tree | 3c9eee7b8813e18269637117ee98a2a23e7ecb15 /test/ruby/test_array.rb | |
| parent | ccadd52d80d3282defd3d1d9c2ed57279f40f379 (diff) | |
| download | ruby-ccd46e878df5d1407ba24eb870327367e5705f8f.tar.gz ruby-ccd46e878df5d1407ba24eb870327367e5705f8f.tar.xz ruby-ccd46e878df5d1407ba24eb870327367e5705f8f.zip | |
Add extend testcase for #first, #last, #shift, #unshift, #pop, #push methods.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
| -rw-r--r-- | test/ruby/test_array.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 3e63dd2f5..79e658fa8 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -98,4 +98,32 @@ class TestArray < Test::Unit::TestCase x.concat(x) assert_equal([1,2,3,1,2,3], x) 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 |
