diff options
| author | yui-knk <spiketeika@gmail.com> | 2025-12-02 11:03:02 +0900 |
|---|---|---|
| committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2025-12-11 17:35:39 +0800 |
| commit | c5b51bdd8c69ae038daf80cb227df854ca0110f1 (patch) | |
| tree | 56fc18b5ab5c4e99bfcd12e6ccb9e977dbb0026d /test/ruby | |
| parent | 278a93a1bb721427ab1a2fa8d68c6f916c39de1d (diff) | |
[Bug #21712] Allow `.()` call for command with block
This commit allows codes like `a b do end.()` and `a b do end&.()`.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_parse.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 78a5638647..9fa4dad41e 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -352,6 +352,21 @@ class TestParse < Test::Unit::TestCase assert_equal("foobar", b) end + def test_call_command + a = b = nil + o = Object.new + def o.m(*arg); proc {|a| arg.join + a }; end + + assert_nothing_raised do + o.instance_eval <<-END, __FILE__, __LINE__+1 + a = o.m "foo", "bar" do end.("buz") + b = o.m "foo", "bar" do end::("buz") + END + end + assert_equal("foobarbuz", a) + assert_equal("foobarbuz", b) + end + def test_xstring assert_raise(Errno::ENOENT) do eval("``") |
