summaryrefslogtreecommitdiff
path: root/spec/rubyspec/core/array/constructor_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/core/array/constructor_spec.rb')
-rw-r--r--spec/rubyspec/core/array/constructor_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/rubyspec/core/array/constructor_spec.rb b/spec/rubyspec/core/array/constructor_spec.rb
new file mode 100644
index 0000000000..8ec2e5de1e
--- /dev/null
+++ b/spec/rubyspec/core/array/constructor_spec.rb
@@ -0,0 +1,24 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
+
+describe "Array.[]" do
+ it "returns a new array populated with the given elements" do
+ obj = Object.new
+ Array.[](5, true, nil, 'a', "Ruby", obj).should == [5, true, nil, "a", "Ruby", obj]
+
+ a = ArraySpecs::MyArray.[](5, true, nil, 'a', "Ruby", obj)
+ a.should be_an_instance_of(ArraySpecs::MyArray)
+ a.inspect.should == [5, true, nil, "a", "Ruby", obj].inspect
+ end
+end
+
+describe "Array[]" do
+ it "is a synonym for .[]" do
+ obj = Object.new
+ Array[5, true, nil, 'a', "Ruby", obj].should == Array.[](5, true, nil, "a", "Ruby", obj)
+
+ a = ArraySpecs::MyArray[5, true, nil, 'a', "Ruby", obj]
+ a.should be_an_instance_of(ArraySpecs::MyArray)
+ a.inspect.should == [5, true, nil, "a", "Ruby", obj].inspect
+ end
+end