summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaĆ­que Kandy Koga <kaiquekandykoga@gmail.com>2023-01-18 02:25:11 -0300
committerGitHub <noreply@github.com>2023-01-17 21:25:11 -0800
commit46066d0b96473589038810ac3aa19a1e26fdb837 (patch)
tree5ac5a4b0ac2f244b5d6ba718fbff274e4f9f3e72
parent5ce3855d90c860a375806ff3127c8d7480c06b6a (diff)
downloadruby-46066d0b96473589038810ac3aa19a1e26fdb837.tar.gz
Change ArgumentError message when Comparable#clamp receives min value higher than max value
-rw-r--r--compar.c2
-rw-r--r--test/ruby/test_comparable.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/compar.c b/compar.c
index 040f77975e..dc157fd241 100644
--- a/compar.c
+++ b/compar.c
@@ -229,7 +229,7 @@ cmp_clamp(int argc, VALUE *argv, VALUE x)
}
}
if (!NIL_P(min) && !NIL_P(max) && cmpint(min, max) > 0) {
- rb_raise(rb_eArgError, "min argument must be smaller than max argument");
+ rb_raise(rb_eArgError, "min argument must be less than or equal to max argument");
}
if (!NIL_P(min)) {
diff --git a/test/ruby/test_comparable.rb b/test/ruby/test_comparable.rb
index b849217b7d..4a90d443bf 100644
--- a/test/ruby/test_comparable.rb
+++ b/test/ruby/test_comparable.rb
@@ -85,7 +85,7 @@ class TestComparable < Test::Unit::TestCase
assert_equal(1, @o.clamp(1, 1))
assert_equal(@o, @o.clamp(0, 0))
- assert_raise_with_message(ArgumentError, 'min argument must be smaller than max argument') {
+ assert_raise_with_message(ArgumentError, 'min argument must be less than or equal to max argument') {
@o.clamp(2, 1)
}
end
@@ -115,7 +115,7 @@ class TestComparable < Test::Unit::TestCase
assert_raise_with_message(*exc) {@o.clamp(-1...0)}
assert_raise_with_message(*exc) {@o.clamp(...2)}
- assert_raise_with_message(ArgumentError, 'min argument must be smaller than max argument') {
+ assert_raise_with_message(ArgumentError, 'min argument must be less than or equal to max argument') {
@o.clamp(2..1)
}
end