summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2026-02-05 20:38:00 +0100
committerBenoit Daloze <eregontp@gmail.com>2026-02-07 10:06:36 +0100
commitd066b9e01ccb2260fac8b2580c10e73335c7c7db (patch)
treeece08ae6b0309149e09a640a3b41537a6485ee13 /test
parent96d00640978d78ede1f5b2b63e422cfd1e849891 (diff)
Refactor type error to be more consistent
[Bug #21864] Co-Authored-By: Benoit Daloze <eregontp@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/error_highlight/test_error_highlight.rb7
-rw-r--r--test/ruby/test_exception.rb6
-rw-r--r--test/ruby/test_integer.rb2
3 files changed, 8 insertions, 7 deletions
diff --git a/test/error_highlight/test_error_highlight.rb b/test/error_highlight/test_error_highlight.rb
index ec39b1c4db..5f664de502 100644
--- a/test/error_highlight/test_error_highlight.rb
+++ b/test/error_highlight/test_error_highlight.rb
@@ -1085,10 +1085,11 @@ nil can't be coerced into Integer (TypeError)
end
end
+ OF_NIL_INTO_INTEGER = RUBY_VERSION < "4.1." ? "from nil to integer" : "of nil into Integer"
def test_args_CALL_2
v = []
assert_error_message(TypeError, <<~END) do
-no implicit conversion from nil to integer (TypeError)
+no implicit conversion #{OF_NIL_INTO_INTEGER} (TypeError)
v[nil]
^^^
@@ -1115,7 +1116,7 @@ undefined method `[]=' for #{ recv }
def test_args_ATTRASGN_2
v = []
assert_error_message(TypeError, <<~END) do
-no implicit conversion from nil to integer (TypeError)
+no implicit conversion #{OF_NIL_INTO_INTEGER} (TypeError)
v [nil] = 1
^^^^^^^^
@@ -1177,7 +1178,7 @@ no implicit conversion of Symbol into String (TypeError)
v = []
assert_error_message(TypeError, <<~END) do
-no implicit conversion from nil to integer (TypeError)
+no implicit conversion #{OF_NIL_INTO_INTEGER} (TypeError)
v [nil] += 42
^^^^^^^^^^
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 31e5aa9f6b..4365150a13 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1542,13 +1542,13 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
def a.to_a = 1
def a.to_hash = 1
def a.to_proc = 1
- assert_raise_with_message(TypeError, "can't convert TestException::Ex to Array (TestException::Ex#to_a gives Integer)") do
+ assert_raise_with_message(TypeError, "can't convert TestException::Ex into Array (TestException::Ex#to_a gives Integer)") do
x(*a)
end
- assert_raise_with_message(TypeError, "can't convert TestException::Ex to Hash (TestException::Ex#to_hash gives Integer)") do
+ assert_raise_with_message(TypeError, "can't convert TestException::Ex into Hash (TestException::Ex#to_hash gives Integer)") do
x(**a)
end
- assert_raise_with_message(TypeError, "can't convert TestException::Ex to Proc (TestException::Ex#to_proc gives Integer)") do
+ assert_raise_with_message(TypeError, "can't convert TestException::Ex into Proc (TestException::Ex#to_proc gives Integer)") do
x(&a)
end
end
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index f9bf4fa20c..c3d9d311c8 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -751,7 +751,7 @@ class TestInteger < Test::Unit::TestCase
o = Object.new
def o.to_int; Object.new; end
- assert_raise_with_message(TypeError, /can't convert Object to Integer/) {Integer.try_convert(o)}
+ assert_raise_with_message(TypeError, /can't convert Object into Integer/) {Integer.try_convert(o)}
end
def test_ceildiv