From 7b10660974dcdd7882a48a62cfc2a32c4a17aa85 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 20 May 2025 17:28:30 -0700 Subject: Use rb_inspect for Ractor error Previously the object was used directly, which calls `to_s` if defined. We should use rb_inspect to get a value suitable for display to the programmer. --- test/ruby/test_ractor.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_ractor.rb b/test/ruby/test_ractor.rb index ec94df361f..e61c6beffc 100644 --- a/test/ruby/test_ractor.rb +++ b/test/ruby/test_ractor.rb @@ -60,6 +60,14 @@ class TestRactor < Test::Unit::TestCase assert_unshareable(x, "can not make shareable object for #", exception: Ractor::Error) end + def test_shareability_error_uses_inspect + x = (+"").instance_exec { method(:to_s) } + def x.to_s + raise "this should not be called" + end + assert_unshareable(x, "can not make shareable object for #", exception: Ractor::Error) + end + def test_default_thread_group assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; -- cgit v1.2.3