mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
cont.c: fix root fiber to_s
* cont.c (fiber_to_s): fix Fiber#to_s on root fibers which have no procs. [ruby-core:82629] [Bug #13859] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
caf92db486
commit
0465916576
2 changed files with 9 additions and 1 deletions
9
cont.c
9
cont.c
|
@ -1753,8 +1753,15 @@ fiber_to_s(VALUE fibval)
|
||||||
char status_info[0x10];
|
char status_info[0x10];
|
||||||
|
|
||||||
GetFiberPtr(fibval, fib);
|
GetFiberPtr(fibval, fib);
|
||||||
GetProcPtr(fib->first_proc, proc);
|
|
||||||
snprintf(status_info, 0x10, " (%s)", fiber_status_name(fib->status));
|
snprintf(status_info, 0x10, " (%s)", fiber_status_name(fib->status));
|
||||||
|
if (!rb_obj_is_proc(fib->first_proc)) {
|
||||||
|
VALUE str = rb_any_to_s(fibval);
|
||||||
|
strlcat(status_info, ">", sizeof(status_info));
|
||||||
|
rb_str_set_len(str, RSTRING_LEN(str)-1);
|
||||||
|
rb_str_cat_cstr(str, status_info);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
GetProcPtr(fib->first_proc, proc);
|
||||||
return rb_block_to_s(fibval, &proc->block, status_info);
|
return rb_block_to_s(fibval, &proc->block, status_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -363,6 +363,7 @@ class TestFiber < Test::Unit::TestCase
|
||||||
assert_match(/suspended/, f.to_s)
|
assert_match(/suspended/, f.to_s)
|
||||||
f.resume
|
f.resume
|
||||||
assert_match(/terminated/, f.to_s)
|
assert_match(/terminated/, f.to_s)
|
||||||
|
assert_match(/resumed/, Fiber.current.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue