[#3006] CVS repository — "Eugene Scripnik" <hoaz@...>

Hello.

21 messages 2004/06/16
[#3008] Re: CVS repository — ts <decoux@...> 2004/06/16

>>>>> "E" == Eugene Scripnik <hoaz@gala.net> writes:

[#3009] Re: CVS repository — Michal Rokos <michal@...> 2004/06/16

Hi!

[#3057] Ruby 1.8.2 to be released. — matz@... (Yukihiro Matsumoto)

Hi,

20 messages 2004/06/23

Re: [Patch] Array#shift(n)

From: Michal Rokos <michal@...>
Date: 2004-06-16 07:28:14 UTC
List: ruby-core #3007
Hello,

On Tuesday 15 of June 2004 15:16, nobu.nokada@softhome.net wrote:
> And, Michal, do you have the test cases?

Here they come...

	Michal

Index: test/ruby/test_array.rb
===================================================================
RCS file: /var/cvs/src/ruby/test/ruby/test_array.rb,v
retrieving revision 1.4
diff -u -p -r1.4 test_array.rb
--- test/ruby/test_array.rb     18 Feb 2004 13:08:07 -0000      1.4
+++ test/ruby/test_array.rb     16 Jun 2004 07:27:46 -0000
@@ -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

In This Thread