summaryrefslogtreecommitdiff
path: root/spec/ruby/core/array/fill_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/array/fill_spec.rb')
-rw-r--r--spec/ruby/core/array/fill_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/ruby/core/array/fill_spec.rb b/spec/ruby/core/array/fill_spec.rb
index 1c1beef25e..0f44d3c010 100644
--- a/spec/ruby/core/array/fill_spec.rb
+++ b/spec/ruby/core/array/fill_spec.rb
@@ -314,4 +314,13 @@ describe "Array#fill with (filler, range)" do
def obj.<=>(rhs); rhs == self ? 0 : nil end
-> { [].fill('a', obj..obj) }.should raise_error(TypeError)
end
+
+ ruby_version_is "2.6" do
+ it "works with endless ranges" do
+ [1, 2, 3, 4].fill('x', eval("(1..)")).should == [1, 'x', 'x', 'x']
+ [1, 2, 3, 4].fill('x', eval("(3...)")).should == [1, 2, 3, 'x']
+ [1, 2, 3, 4].fill(eval("(1..)")) { |x| x + 2 }.should == [1, 3, 4, 5]
+ [1, 2, 3, 4].fill(eval("(3...)")) { |x| x + 2 }.should == [1, 2, 3, 5]
+ end
+ end
end