Skip to content

Commit 507a965

Browse files
Fix inspect format for Ruby >= 3.4.0
1 parent bf693fd commit 507a965

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

test/helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ def format_trace(args)
4545
def monotonic_clock
4646
::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
4747
end
48+
49+
def inspect_method_name_for(klass_name, method_name)
50+
if RUBY_VERSION < '3.4.0'
51+
"`#{method_name}'"
52+
else
53+
"'#{klass_name}##{method_name}'"
54+
end
55+
end
4856
end
4957

5058
class MiniTest::Test

test/test_fiber.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,16 +619,17 @@ def test_inspect
619619
f = spin(:baz) { :foo }
620620

621621
expected = format(
622-
'#<Fiber baz:%s %s:%d:in `test_inspect\' (runnable)>',
622+
"#<Fiber baz:%s %s:%d:in #{inspect_method_name_for(self.class.name, __method__.to_s)} (runnable)>",
623623
f.object_id,
624624
__FILE__,
625625
spin_line_no
626626
)
627627
assert_equal expected, f.inspect
628628

629629
f.await
630+
630631
expected = format(
631-
'#<Fiber baz:%s %s:%d:in `test_inspect\' (dead)>',
632+
"#<Fiber baz:%s %s:%d:in #{inspect_method_name_for(self.class.name, __method__.to_s)} (dead)>",
632633
f.object_id,
633634
__FILE__,
634635
spin_line_no

test/test_thread.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_that_suspend_returns_immediately_if_no_watchers
133133
Thread.backend.trace_proc = proc {|*r| records << r }
134134
suspend
135135
assert_equal [
136-
[:block, Fiber.current, ["#{__FILE__}:#{__LINE__ - 2}:in `test_that_suspend_returns_immediately_if_no_watchers'"] + caller]
136+
[:block, Fiber.current, ["#{__FILE__}:#{__LINE__ - 2}:in #{inspect_method_name_for(self.class.name, __method__.to_s)}"] + caller]
137137
], records
138138
ensure
139139
Thread.backend.trace_proc = nil

0 commit comments

Comments
 (0)