Skip to content

Commit d8c88f0

Browse files
committed
Add spec for Array#[a, b] = "frozen string literal".freeze
* See #2355
1 parent 72ce69e commit d8c88f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

spec/ruby/core/array/element_set_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
a[3, 2] = ['a', 'b', 'c', 'd']
3737
a.should == [2, 2, 3, "a", "b", "c", "d", 6]
3838
end
39+
3940
it "replaces the section defined by [start,length] with the given values" do
4041
a = [1, 2, 3, 4, 5, 6]
4142
a[3, 2] = 'a', 'b', 'c', 'd'
@@ -169,6 +170,7 @@
169170
ary[1...1] = []
170171
ary.should == [1, 2, 3]
171172
end
173+
172174
it "does nothing if the section defined by range has negative width and the rhs is an empty array" do
173175
ary = [1, 2, 3, 4, 5]
174176
ary[1...0] = []
@@ -284,6 +286,12 @@ def obj.to_ary() [1, 2, 3] end
284286
(a[2, 3] = [4, 5]).should == [4, 5]
285287
end
286288

289+
it "accepts a frozen String literal as RHS" do
290+
a = ['a', 'b', 'c']
291+
a[0, 2] = 'd'.freeze
292+
a.should == ['d', 'c']
293+
end
294+
287295
it "just sets the section defined by [start,length] to nil even if the rhs is nil" do
288296
a = ['a', 'b', 'c', 'd', 'e']
289297
a[1, 3] = nil

0 commit comments

Comments
 (0)