diff options
Diffstat (limited to 'spec/ruby/core/array')
-rw-r--r-- | spec/ruby/core/array/append_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/collect_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/array/element_reference_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/element_set_spec.rb | 35 | ||||
-rw-r--r-- | spec/ruby/core/array/index_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/length_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/map_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/array/prepend_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/push_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/replace_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/size_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/slice_spec.rb | 2 | ||||
-rw-r--r-- | spec/ruby/core/array/unshift_spec.rb | 2 |
13 files changed, 41 insertions, 22 deletions
diff --git a/spec/ruby/core/array/append_spec.rb b/spec/ruby/core/array/append_spec.rb index 5131e71b3c..ff47b5d9a8 100644 --- a/spec/ruby/core/array/append_spec.rb +++ b/spec/ruby/core/array/append_spec.rb @@ -37,6 +37,6 @@ end ruby_version_is "2.5" do describe "Array#append" do - it_behaves_like(:array_push, :append) + it_behaves_like :array_push, :append end end diff --git a/spec/ruby/core/array/collect_spec.rb b/spec/ruby/core/array/collect_spec.rb index 1c2c28c6bd..2b0814d307 100644 --- a/spec/ruby/core/array/collect_spec.rb +++ b/spec/ruby/core/array/collect_spec.rb @@ -3,9 +3,9 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/collect', __FILE__) describe "Array#collect" do - it_behaves_like(:array_collect, :collect) + it_behaves_like :array_collect, :collect end describe "Array#collect!" do - it_behaves_like(:array_collect_b, :collect!) + it_behaves_like :array_collect_b, :collect! end diff --git a/spec/ruby/core/array/element_reference_spec.rb b/spec/ruby/core/array/element_reference_spec.rb index 55b6b73d1e..5d6f4cca36 100644 --- a/spec/ruby/core/array/element_reference_spec.rb +++ b/spec/ruby/core/array/element_reference_spec.rb @@ -3,7 +3,7 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/slice', __FILE__) describe "Array#[]" do - it_behaves_like(:array_slice, :[]) + it_behaves_like :array_slice, :[] end describe "Array.[]" do diff --git a/spec/ruby/core/array/element_set_spec.rb b/spec/ruby/core/array/element_set_spec.rb index 9c6a1d05a8..28f3aa5eee 100644 --- a/spec/ruby/core/array/element_set_spec.rb +++ b/spec/ruby/core/array/element_set_spec.rb @@ -350,11 +350,13 @@ describe "Array#[]= with [m..n]" do it "returns non-array value if non-array value assigned" do a = [1, 2, 3, 4, 5] (a[2..4] = 10).should == 10 + (a.[]=(2..4, 10)).should == 10 end it "returns array if array assigned" do a = [1, 2, 3, 4, 5] (a[2..4] = [7, 8]).should == [7, 8] + (a.[]=(2..4, [7, 8])).should == [7, 8] end it "just sets the section defined by range to nil even if the rhs is nil" do @@ -394,15 +396,32 @@ describe "Array#[]= with [m..n]" do a.should == [1, 2, 3, 8, 4, 5] end - it "accepts Range subclasses" do - a = [1, 2, 3, 4] - range_incl = ArraySpecs::MyRange.new(1, 2) - range_excl = ArraySpecs::MyRange.new(-3, -1, true) + describe "Range subclasses" do + before :each do + @range_incl = ArraySpecs::MyRange.new(1, 2) + @range_excl = ArraySpecs::MyRange.new(-3, -1, true) + end + + it "accepts Range subclasses" do + a = [1, 2, 3, 4] + + a[@range_incl] = ["a", "b"] + a.should == [1, "a", "b", 4] + a[@range_excl] = ["A", "B"] + a.should == [1, "A", "B", 4] + end + + it "returns non-array value if non-array value assigned" do + a = [1, 2, 3, 4, 5] + (a[@range_incl] = 10).should == 10 + (a.[]=(@range_incl, 10)).should == 10 + end - a[range_incl] = ["a", "b"] - a.should == [1, "a", "b", 4] - a[range_excl] = ["A", "B"] - a.should == [1, "A", "B", 4] + it "returns array if array assigned" do + a = [1, 2, 3, 4, 5] + (a[@range_incl] = [7, 8]).should == [7, 8] + a.[]=(@range_incl, [7, 8]).should == [7, 8] + end end end diff --git a/spec/ruby/core/array/index_spec.rb b/spec/ruby/core/array/index_spec.rb index 55ed7b2a94..69c23b1a08 100644 --- a/spec/ruby/core/array/index_spec.rb +++ b/spec/ruby/core/array/index_spec.rb @@ -2,5 +2,5 @@ require File.expand_path('../../../spec_helper', __FILE__) require File.expand_path('../shared/index', __FILE__) describe "Array#index" do - it_behaves_like(:array_index, :index) + it_behaves_like :array_index, :index end diff --git a/spec/ruby/core/array/length_spec.rb b/spec/ruby/core/array/length_spec.rb index 6f4469dda5..ad795e5ff7 100644 --- a/spec/ruby/core/array/length_spec.rb +++ b/spec/ruby/core/array/length_spec.rb @@ -3,5 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/length', __FILE__) describe "Array#length" do - it_behaves_like(:array_length, :length) + it_behaves_like :array_length, :length end diff --git a/spec/ruby/core/array/map_spec.rb b/spec/ruby/core/array/map_spec.rb index c23bb4241a..bcfd8d639d 100644 --- a/spec/ruby/core/array/map_spec.rb +++ b/spec/ruby/core/array/map_spec.rb @@ -3,9 +3,9 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/collect', __FILE__) describe "Array#map" do - it_behaves_like(:array_collect, :map) + it_behaves_like :array_collect, :map end describe "Array#map!" do - it_behaves_like(:array_collect_b, :map!) + it_behaves_like :array_collect_b, :map! end diff --git a/spec/ruby/core/array/prepend_spec.rb b/spec/ruby/core/array/prepend_spec.rb index d8c6bad1a8..d859a698c5 100644 --- a/spec/ruby/core/array/prepend_spec.rb +++ b/spec/ruby/core/array/prepend_spec.rb @@ -4,6 +4,6 @@ require File.expand_path('../shared/unshift', __FILE__) ruby_version_is "2.5" do describe "Array#prepend" do - it_behaves_like(:array_unshift, :prepend) + it_behaves_like :array_unshift, :prepend end end diff --git a/spec/ruby/core/array/push_spec.rb b/spec/ruby/core/array/push_spec.rb index 0207474579..67f90aff81 100644 --- a/spec/ruby/core/array/push_spec.rb +++ b/spec/ruby/core/array/push_spec.rb @@ -3,5 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/push', __FILE__) describe "Array#push" do - it_behaves_like(:array_push, :push) + it_behaves_like :array_push, :push end diff --git a/spec/ruby/core/array/replace_spec.rb b/spec/ruby/core/array/replace_spec.rb index e8b0d53e04..92f84cba50 100644 --- a/spec/ruby/core/array/replace_spec.rb +++ b/spec/ruby/core/array/replace_spec.rb @@ -3,5 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/replace', __FILE__) describe "Array#replace" do - it_behaves_like(:array_replace, :replace) + it_behaves_like :array_replace, :replace end diff --git a/spec/ruby/core/array/size_spec.rb b/spec/ruby/core/array/size_spec.rb index 2c8a18ade6..6ac5ebf41b 100644 --- a/spec/ruby/core/array/size_spec.rb +++ b/spec/ruby/core/array/size_spec.rb @@ -3,5 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/length', __FILE__) describe "Array#size" do - it_behaves_like(:array_length, :size) + it_behaves_like :array_length, :size end diff --git a/spec/ruby/core/array/slice_spec.rb b/spec/ruby/core/array/slice_spec.rb index 31d2983aef..fd31c6e323 100644 --- a/spec/ruby/core/array/slice_spec.rb +++ b/spec/ruby/core/array/slice_spec.rb @@ -156,5 +156,5 @@ describe "Array#slice!" do end describe "Array#slice" do - it_behaves_like(:array_slice, :slice) + it_behaves_like :array_slice, :slice end diff --git a/spec/ruby/core/array/unshift_spec.rb b/spec/ruby/core/array/unshift_spec.rb index eb224acfe8..e2203eeeb1 100644 --- a/spec/ruby/core/array/unshift_spec.rb +++ b/spec/ruby/core/array/unshift_spec.rb @@ -3,5 +3,5 @@ require File.expand_path('../fixtures/classes', __FILE__) require File.expand_path('../shared/unshift', __FILE__) describe "Array#unshift" do - it_behaves_like(:array_unshift, :unshift) + it_behaves_like :array_unshift, :unshift end |