Updated RubySpec source to 55122684.
[rbx.git] / spec / frozen / 1.8 / core / array / push_spec.rb
blob907f9101347843dceab8133f04b368a07662255b
1 require File.dirname(__FILE__) + '/../../spec_helper'
2 require File.dirname(__FILE__) + '/fixtures/classes'
4 describe "Array#push" do
5   it "appends the arguments to the array" do
6     a = [ "a", "b", "c" ]
7     a.push("d", "e", "f").should equal(a)
8     a.push().should == ["a", "b", "c", "d", "e", "f"]
9     a.push(5)
10     a.should == ["a", "b", "c", "d", "e", "f", 5]
11   end
13   it "isn't confused by previous shift" do
14     a = [ "a", "b", "c" ]
15     a.shift
16     a.push("foo")
17     a.should == ["b", "c", "foo"]
18   end
19   
20   compliant_on :ruby, :jruby do
21     it "raises a TypeError on a frozen array if modification takes place" do
22       lambda { ArraySpecs.frozen_array.push(1) }.should raise_error(TypeError)
23     end
25     it "does not raise on a frozen array if no modification is made" do
26       ArraySpecs.frozen_array.push.should == [1, 2, 3]
27     end
28   end
29 end