Skip to content

Commit

Permalink
Fix inspect format for Ruby >= 3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
floriandejonckheere committed Sep 16, 2024
1 parent 43e177a commit 93381cd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/test_fiber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,17 +618,25 @@ def test_inspect
spin_line_no = __LINE__ + 1
f = spin(:baz) { :foo }

# Ruby 3.4.0 changed the format of the inspect string
method_name = if RUBY_VERSION < '3.4.0'
'`test_inspect\''
else
'\'FiberTest#test_inspect\''
end

expected = format(
'#<Fiber baz:%s %s:%d:in `test_inspect\' (runnable)>',
"#<Fiber baz:%s %s:%d:in #{method_name} (runnable)>",
f.object_id,
__FILE__,
spin_line_no
)
assert_equal expected, f.inspect

f.await

expected = format(
'#<Fiber baz:%s %s:%d:in `test_inspect\' (dead)>',
"#<Fiber baz:%s %s:%d:in #{method_name} (dead)>",
f.object_id,
__FILE__,
spin_line_no
Expand Down

0 comments on commit 93381cd

Please sign in to comment.