mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update representation (discussed on ruby tracker)
This commit is contained in:
parent
baf482bab4
commit
50cc934145
Notes:
git
2019-11-20 13:43:18 +09:00
2 changed files with 23 additions and 25 deletions
8
proc.c
8
proc.c
|
@ -2830,7 +2830,6 @@ method_inspect(VALUE method)
|
|||
{
|
||||
VALUE params = rb_method_parameters(method);
|
||||
VALUE pair, name, kind;
|
||||
int arg_num = 1;
|
||||
const VALUE req = ID2SYM(rb_intern("req"));
|
||||
const VALUE opt = ID2SYM(rb_intern("opt"));
|
||||
const VALUE keyreq = ID2SYM(rb_intern("keyreq"));
|
||||
|
@ -2850,8 +2849,7 @@ method_inspect(VALUE method)
|
|||
if (NIL_P(name) || name == Qfalse) {
|
||||
// FIXME: can it be reduced to switch/case?
|
||||
if (kind == req || kind == opt) {
|
||||
name = rb_sprintf("arg%d", arg_num);
|
||||
arg_num++;
|
||||
name = rb_str_new2("_");
|
||||
} else if (kind == rest || kind == keyrest) {
|
||||
name = rb_str_new2("");
|
||||
} else if (kind == block) {
|
||||
|
@ -2864,11 +2862,11 @@ method_inspect(VALUE method)
|
|||
if (kind == req) {
|
||||
rb_str_catf(str, "%"PRIsVALUE, name);
|
||||
} else if (kind == opt) {
|
||||
rb_str_catf(str, "%"PRIsVALUE"=<default>", name);
|
||||
rb_str_catf(str, "%"PRIsVALUE"=...", name);
|
||||
} else if (kind == keyreq) {
|
||||
rb_str_catf(str, "%"PRIsVALUE":", name);
|
||||
} else if (kind == key) {
|
||||
rb_str_catf(str, "%"PRIsVALUE": <default>", name);
|
||||
rb_str_catf(str, "%"PRIsVALUE": ...", name);
|
||||
} else if (kind == rest) {
|
||||
rb_str_catf(str, "*%"PRIsVALUE, name);
|
||||
} else if (kind == keyrest) {
|
||||
|
|
|
@ -636,23 +636,23 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_include(method(:m0).inspect, "()")
|
||||
assert_include(method(:m1).inspect, "(a)")
|
||||
assert_include(method(:m2).inspect, "(a, b)")
|
||||
assert_include(method(:mo1).inspect, "(a=<default>, &b)")
|
||||
assert_include(method(:mo2).inspect, "(a, b=<default>)")
|
||||
assert_include(method(:mo1).inspect, "(a=..., &b)")
|
||||
assert_include(method(:mo2).inspect, "(a, b=...)")
|
||||
assert_include(method(:mo3).inspect, "(*a)")
|
||||
assert_include(method(:mo4).inspect, "(a, *b, &c)")
|
||||
assert_include(method(:mo5).inspect, "(a, *b, c)")
|
||||
assert_include(method(:mo6).inspect, "(a, *b, c, &d)")
|
||||
assert_include(method(:mo7).inspect, "(a, b=<default>, *c, d, &e)")
|
||||
assert_include(method(:mo8).inspect, "(a, b=<default>, *, d, &e)")
|
||||
assert_include(method(:ma1).inspect, "(arg1, &b)")
|
||||
assert_include(method(:mo7).inspect, "(a, b=..., *c, d, &e)")
|
||||
assert_include(method(:mo8).inspect, "(a, b=..., *, d, &e)")
|
||||
assert_include(method(:ma1).inspect, "(_, &b)")
|
||||
assert_include(method(:mk1).inspect, "(**)")
|
||||
assert_include(method(:mk2).inspect, "(**o)")
|
||||
assert_include(method(:mk3).inspect, "(a, **o)")
|
||||
assert_include(method(:mk4).inspect, "(a=<default>, **o)")
|
||||
assert_include(method(:mk5).inspect, "(a, b=<default>, **o)")
|
||||
assert_include(method(:mk6).inspect, "(a, b=<default>, c, **o)")
|
||||
assert_include(method(:mk7).inspect, "(a, b=<default>, *c, d, **o)")
|
||||
assert_include(method(:mk8).inspect, "(a, b=<default>, *c, d, e:, f: <default>, **o)")
|
||||
assert_include(method(:mk4).inspect, "(a=..., **o)")
|
||||
assert_include(method(:mk5).inspect, "(a, b=..., **o)")
|
||||
assert_include(method(:mk6).inspect, "(a, b=..., c, **o)")
|
||||
assert_include(method(:mk7).inspect, "(a, b=..., *c, d, **o)")
|
||||
assert_include(method(:mk8).inspect, "(a, b=..., *c, d, e:, f: ..., **o)")
|
||||
assert_include(method(:mnk).inspect, "(**nil)")
|
||||
end
|
||||
|
||||
|
@ -660,23 +660,23 @@ class TestMethod < Test::Unit::TestCase
|
|||
assert_include(self.class.instance_method(:m0).inspect, "()")
|
||||
assert_include(self.class.instance_method(:m1).inspect, "(a)")
|
||||
assert_include(self.class.instance_method(:m2).inspect, "(a, b)")
|
||||
assert_include(self.class.instance_method(:mo1).inspect, "(a=<default>, &b)")
|
||||
assert_include(self.class.instance_method(:mo2).inspect, "(a, b=<default>)")
|
||||
assert_include(self.class.instance_method(:mo1).inspect, "(a=..., &b)")
|
||||
assert_include(self.class.instance_method(:mo2).inspect, "(a, b=...)")
|
||||
assert_include(self.class.instance_method(:mo3).inspect, "(*a)")
|
||||
assert_include(self.class.instance_method(:mo4).inspect, "(a, *b, &c)")
|
||||
assert_include(self.class.instance_method(:mo5).inspect, "(a, *b, c)")
|
||||
assert_include(self.class.instance_method(:mo6).inspect, "(a, *b, c, &d)")
|
||||
assert_include(self.class.instance_method(:mo7).inspect, "(a, b=<default>, *c, d, &e)")
|
||||
assert_include(self.class.instance_method(:mo8).inspect, "(a, b=<default>, *, d, &e)")
|
||||
assert_include(self.class.instance_method(:ma1).inspect, "(arg1, &b)")
|
||||
assert_include(self.class.instance_method(:mo7).inspect, "(a, b=..., *c, d, &e)")
|
||||
assert_include(self.class.instance_method(:mo8).inspect, "(a, b=..., *, d, &e)")
|
||||
assert_include(self.class.instance_method(:ma1).inspect, "(_, &b)")
|
||||
assert_include(self.class.instance_method(:mk1).inspect, "(**)")
|
||||
assert_include(self.class.instance_method(:mk2).inspect, "(**o)")
|
||||
assert_include(self.class.instance_method(:mk3).inspect, "(a, **o)")
|
||||
assert_include(self.class.instance_method(:mk4).inspect, "(a=<default>, **o)")
|
||||
assert_include(self.class.instance_method(:mk5).inspect, "(a, b=<default>, **o)")
|
||||
assert_include(self.class.instance_method(:mk6).inspect, "(a, b=<default>, c, **o)")
|
||||
assert_include(self.class.instance_method(:mk7).inspect, "(a, b=<default>, *c, d, **o)")
|
||||
assert_include(self.class.instance_method(:mk8).inspect, "(a, b=<default>, *c, d, e:, f: <default>, **o)")
|
||||
assert_include(self.class.instance_method(:mk4).inspect, "(a=..., **o)")
|
||||
assert_include(self.class.instance_method(:mk5).inspect, "(a, b=..., **o)")
|
||||
assert_include(self.class.instance_method(:mk6).inspect, "(a, b=..., c, **o)")
|
||||
assert_include(self.class.instance_method(:mk7).inspect, "(a, b=..., *c, d, **o)")
|
||||
assert_include(self.class.instance_method(:mk8).inspect, "(a, b=..., *c, d, e:, f: ..., **o)")
|
||||
assert_include(self.class.instance_method(:mnk).inspect, "(**nil)")
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue