[前][次][番号順一覧][スレッド一覧]

ruby-changes:58852

From: zverok <ko1@a...>
Date: Wed, 20 Nov 2019 13:43:15 +0900 (JST)
Subject: [ruby-changes:58852] 50cc934145 (master): Update representation (discussed on ruby tracker)

https://git.ruby-lang.org/ruby.git/commit/?id=50cc934145

From 50cc9341450cfbdf9a40df3d38600d8d2854a0a3 Mon Sep 17 00:00:00 2001
From: zverok <zverok.offline@g...>
Date: Wed, 20 Nov 2019 02:33:20 +0200
Subject: Update representation (discussed on ruby tracker)


diff --git a/proc.c b/proc.c
index e37ac1c..9859116 100644
--- a/proc.c
+++ b/proc.c
@@ -2830,7 +2830,6 @@ method_inspect(VALUE method) https://github.com/ruby/ruby/blob/trunk/proc.c#L2830
     {
         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) https://github.com/ruby/ruby/blob/trunk/proc.c#L2849
             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) https://github.com/ruby/ruby/blob/trunk/proc.c#L2862
             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) {
diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb
index efd5fae..be5afab 100644
--- a/test/ruby/test_method.rb
+++ b/test/ruby/test_method.rb
@@ -636,23 +636,23 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L636
     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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L660
     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
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]