From 32a27216bb6e1df453f177901fcbb346428ded8d Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 26 Jan 2026 08:58:08 +0900 Subject: [PATCH] test: add parentheses to method calls on assignment RHS Preparation for future grammar simplification that may require parentheses for method calls with arguments on the right-hand side of assignments. Co-authored-by: Claude --- mrbgems/mruby-catch/test/catch.rb | 4 ++-- mrbgems/mruby-io/test/io.rb | 28 ++++++++++++++-------------- mrbgems/mruby-struct/test/struct.rb | 4 ++-- test/t/exception.rb | 2 +- test/t/nomethoderror.rb | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/mrbgems/mruby-catch/test/catch.rb b/mrbgems/mruby-catch/test/catch.rb index 38a4eb907..418f1bdb6 100644 --- a/mrbgems/mruby-catch/test/catch.rb +++ b/mrbgems/mruby-catch/test/catch.rb @@ -1,6 +1,6 @@ assert "return throw value" do val = ["val"] - result = catch :foo do + result = catch(:foo) do loop do loop do begin @@ -22,7 +22,7 @@ assert "no throw" do end assert "no throw value" do - result = catch :foo do + result = catch(:foo) do throw :foo 1 end diff --git a/mrbgems/mruby-io/test/io.rb b/mrbgems/mruby-io/test/io.rb index c5887d969..38af70e9a 100644 --- a/mrbgems/mruby-io/test/io.rb +++ b/mrbgems/mruby-io/test/io.rb @@ -290,7 +290,7 @@ end assert('IO.sysopen, IO#sysread') do fd = IO.sysopen $mrbtest_io_rfname - io = IO.new fd + io = IO.new(fd) str1 = " " str2 = io.sysread(5, str1) assert_equal $mrbtest_io_msg[0,5], str1 @@ -311,14 +311,14 @@ assert('IO.sysopen, IO#sysread') do io.closed? fd = IO.sysopen $mrbtest_io_wfname, "w" - io = IO.new fd, "w" + io = IO.new(fd, "w") assert_raise(IOError) { io.sysread(1) } io.close end assert('IO.sysopen, IO#syswrite') do fd = IO.sysopen $mrbtest_io_wfname, "w" - io = IO.new fd, "w" + io = IO.new(fd, "w") str = "abcdefg" len = io.syswrite(str) assert_equal str.size, len @@ -358,7 +358,7 @@ end assert('IO#pos=, IO#seek') do fd = IO.sysopen $mrbtest_io_rfname - io = IO.new fd + io = IO.new(fd) def io._buf @buf end @@ -371,7 +371,7 @@ end assert('IO#rewind') do fd = IO.sysopen $mrbtest_io_rfname - io = IO.new fd + io = IO.new(fd) assert_equal 'm', io.getc assert_equal 1, io.pos assert_equal 0, io.rewind @@ -381,7 +381,7 @@ end assert('IO#gets') do fd = IO.sysopen $mrbtest_io_rfname - io = IO.new fd + io = IO.new(fd) # gets without arguments assert_equal $mrbtest_io_msg, io.gets, "gets without arguments" @@ -404,14 +404,14 @@ assert('IO#gets') do # reading many-lines file. fd = IO.sysopen $mrbtest_io_wfname, "w" - io = IO.new fd, "w" + io = IO.new(fd, "w") io.write "0123456789" * 2 + "\na" assert_equal 22 + $cr, io.pos io.close assert_equal true, io.closed? fd = IO.sysopen $mrbtest_io_wfname - io = IO.new fd + io = IO.new(fd) line = io.gets # gets first line @@ -430,7 +430,7 @@ end assert('IO#gets - paragraph mode') do fd = IO.sysopen $mrbtest_io_wfname, "w" - io = IO.new fd, "w" + io = IO.new(fd, "w") io.write "0" * 10 + "\n" io.write "1" * 10 + "\n\n" io.write "2" * 10 + "\n" @@ -438,7 +438,7 @@ assert('IO#gets - paragraph mode') do io.close fd = IO.sysopen $mrbtest_io_wfname - io = IO.new fd + io = IO.new(fd) para1 = "#{'0' * 10}\n#{'1' * 10}\n\n" text1 = io.gets("") assert_equal para1, text1 @@ -513,14 +513,14 @@ end assert('IO.read') do # empty file fd = IO.sysopen $mrbtest_io_wfname, "w" - io = IO.new fd, "w" + io = IO.new(fd, "w") io.close assert_equal "", IO.read($mrbtest_io_wfname) assert_equal nil, IO.read($mrbtest_io_wfname, 1) # one byte file fd = IO.sysopen $mrbtest_io_wfname, "w" - io = IO.new fd, "w" + io = IO.new(fd, "w") io.write "123" io.close assert_equal "123", IO.read($mrbtest_io_wfname) @@ -535,7 +535,7 @@ end assert('IO#fileno') do fd = IO.sysopen $mrbtest_io_rfname - io = IO.new fd + io = IO.new(fd) assert_equal io.fileno, fd assert_equal io.to_i, fd io.close @@ -543,7 +543,7 @@ end assert('IO#close_on_exec') do fd = IO.sysopen $mrbtest_io_wfname, "w" - io = IO.new fd, "w" + io = IO.new(fd, "w") begin # IO.sysopen opens a file descriptor with O_CLOEXEC flag. assert_true io.close_on_exec? diff --git a/mrbgems/mruby-struct/test/struct.rb b/mrbgems/mruby-struct/test/struct.rb index deed70680..b2a345186 100644 --- a/mrbgems/mruby-struct/test/struct.rb +++ b/mrbgems/mruby-struct/test/struct.rb @@ -197,7 +197,7 @@ assert("Struct.new generates subclass of Struct") do end assert 'Struct#freeze' do - c = Struct.new :m + c = Struct.new(:m) o = c.new o.m = :test @@ -210,7 +210,7 @@ assert 'Struct#freeze' do end assert 'method visibility with Struct' do - c = Struct.new :r, :g, :b do + c = Struct.new(:r, :g, :b) do def good! "GOOD!" end diff --git a/test/t/exception.rb b/test/t/exception.rb index 2a95a8acf..d842c6ce1 100644 --- a/test/t/exception.rb +++ b/test/t/exception.rb @@ -46,7 +46,7 @@ assert('NameError', '15.2.31') do raise NameError.new end - e = NameError.new "msg", "name" + e = NameError.new("msg", "name") assert_equal "msg", e.message assert_equal "name", e.name end diff --git a/test/t/nomethoderror.rb b/test/t/nomethoderror.rb index 5fed79689..0eb8fc69e 100644 --- a/test/t/nomethoderror.rb +++ b/test/t/nomethoderror.rb @@ -9,7 +9,7 @@ assert('NoMethodError', '15.2.32') do end assert('NoMethodError#args', '15.2.32.2.1') do - a = NoMethodError.new 'test', :test, [1, 2] + a = NoMethodError.new('test', :test, [1, 2]) assert_equal [1, 2], a.args assert_nothing_raised do