mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix and add test to Proc#inspect .
This commit is contained in:
committed by
Yukihiro "Matz" Matsumoto
parent
4685a43dd6
commit
6e0c48d758
@@ -84,18 +84,17 @@ mrb_proc_inspect(mrb_state *mrb, mrb_value self)
|
||||
|
||||
if (!MRB_PROC_CFUNC_P(p)) {
|
||||
mrb_irep *irep = p->body.irep;
|
||||
const char *filename;
|
||||
int32_t line;
|
||||
mrb_str_cat_lit(mrb, str, "@");
|
||||
|
||||
if (irep->filename) {
|
||||
mrb_str_cat_cstr(mrb, str, irep->filename);
|
||||
}
|
||||
else {
|
||||
mrb_str_cat_lit(mrb, str, "-");
|
||||
}
|
||||
filename = mrb_debug_get_filename(irep, 0);
|
||||
mrb_str_cat_cstr(mrb, str, filename ? filename : "-");
|
||||
mrb_str_cat_lit(mrb, str, ":");
|
||||
|
||||
if (irep->lines) {
|
||||
mrb_str_append(mrb, str, mrb_fixnum_value(*irep->lines));
|
||||
line = mrb_debug_get_line(irep, 0);
|
||||
if (line != -1) {
|
||||
mrb_str_append(mrb, str, mrb_fixnum_value(line));
|
||||
}
|
||||
else {
|
||||
mrb_str_cat_lit(mrb, str, "-");
|
||||
|
||||
@@ -8,6 +8,11 @@ assert('Proc#source_location') do
|
||||
assert_equal loc[1], 5
|
||||
end
|
||||
|
||||
assert('Proc#inspect') do
|
||||
ins = Proc.new{}.inspect
|
||||
assert_true ins.kind_of? String
|
||||
end
|
||||
|
||||
assert('Proc#lambda?') do
|
||||
assert_true lambda{}.lambda?
|
||||
assert_true !Proc.new{}.lambda?
|
||||
|
||||
Reference in New Issue
Block a user