aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/range/max_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/range/max_spec.rb')
-rw-r--r--spec/ruby/core/range/max_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/ruby/core/range/max_spec.rb b/spec/ruby/core/range/max_spec.rb
index 728053cefd..f2672170d9 100644
--- a/spec/ruby/core/range/max_spec.rb
+++ b/spec/ruby/core/range/max_spec.rb
@@ -51,6 +51,19 @@ describe "Range#max" do
-> { eval("(1..)").max }.should raise_error(RangeError)
end
end
+
+ ruby_version_is "3.0" do
+ it "returns the end point for beginless ranges" do
+ eval("(..1)").max.should == 1
+ eval("(..1.0)").max.should == 1.0
+ end
+
+ it "raises for an exclusive beginless range" do
+ -> {
+ eval("(...1)").max
+ }.should raise_error(TypeError, 'cannot exclude end value with non Integer begin value')
+ end
+ end
end
describe "Range#max given a block" do
@@ -85,4 +98,10 @@ describe "Range#max given a block" do
('z'..'l').max {|x,y| x <=> y}.should be_nil
(5...5).max {|x,y| x <=> y}.should be_nil
end
+
+ ruby_version_is "2.7" do
+ it "raises RangeError when called with custom comparison method on an beginless range" do
+ -> { eval("(..1)").max {|a, b| a} }.should raise_error(RangeError)
+ end
+ end
end