Use a normal method instead of a lambda in bintest/mruby; ref
MODIFY
mrbgems/mruby-bin-mruby/bintest/mruby.rb
mrbgems/mruby-bin-mruby/bintest/mruby.rb
require 'tempfile'
require 'open3'
-assert_mruby = ->(exp_out, exp_err, exp_success, args) do
+def assert_mruby(exp_out, exp_err, exp_success, args)
out, err, stat = Open3.capture3(cmd("mruby"), *args)
assert_operator(exp_out, :===, out, "standard output")
assert_operator(exp_err, :===, err, "standard error")
@@ -9,8 +9,8 @@ assert_mruby = ->(exp_out, exp_err, exp_success, args) do
end
assert('regression for #1564') do
- assert_mruby.("", /\A-e:1:2: syntax error, .*\n\z/, false, %w[-e <<])
- assert_mruby.("", /\A-e:1:3: syntax error, .*\n\z/, false, %w[-e <<-])
+ assert_mruby("", /\A-e:1:2: syntax error, .*\n\z/, false, %w[-e <<])
+ assert_mruby("", /\A-e:1:3: syntax error, .*\n\z/, false, %w[-e <<-])
end
assert('regression for #1572') do
@@ -73,8 +73,8 @@ RUBY
end
assert('mruby -c option') do
- assert_mruby.("Syntax OK\n", "", true, ["-c", "-e", "p 1"])
- assert_mruby.("", /\A-e:1:7: syntax error, .*\n\z/, false, ["-c", "-e", "p 1; 1."])
+ assert_mruby("Syntax OK\n", "", true, ["-c", "-e", "p 1"])
+ assert_mruby("", /\A-e:1:7: syntax error, .*\n\z/, false, ["-c", "-e", "p 1; 1."])
end
assert('mruby -d option') do
@@ -85,11 +85,11 @@ assert('mruby -d option') do
end
assert('mruby -e option (no code specified)') do
- assert_mruby.("", /\A.*: No code specified for -e\n\z/, false, %w[-e])
+ assert_mruby("", /\A.*: No code specified for -e\n\z/, false, %w[-e])
end
assert('mruby -h option') do
- assert_mruby.(/\AUsage: #{Regexp.escape cmd("mruby")} .*/m, "", true, %w[-h])
+ assert_mruby(/\AUsage: #{Regexp.escape cmd("mruby")} .*/m, "", true, %w[-h])
end
assert('mruby -r option') do
@@ -116,30 +116,30 @@ EOS
end
assert('mruby -r option (no library specified)') do
- assert_mruby.("", /\A.*: No library specified for -r\n\z/, false, %w[-r])
+ assert_mruby("", /\A.*: No library specified for -r\n\z/, false, %w[-r])
end
assert('mruby -r option (file not found)') do
- assert_mruby.("", /\A.*: Cannot open library file: .*\n\z/, false, %w[-r _no_exists_])
+ assert_mruby("", /\A.*: Cannot open library file: .*\n\z/, false, %w[-r _no_exists_])
end
assert('mruby invalid short option') do
- assert_mruby.("", /\A.*: invalid option -1 .*\n\z/, false, %w[-1])
+ assert_mruby("", /\A.*: invalid option -1 .*\n\z/, false, %w[-1])
end
assert('mruby invalid long option') do
- assert_mruby.("", /\A.*: invalid option --longopt .*\n\z/, false, %w[--longopt])
+ assert_mruby("", /\A.*: invalid option --longopt .*\n\z/, false, %w[--longopt])
end
assert('unhandled exception') do
- assert_mruby.("", /\bEXCEPTION\b.*\n\z/, false, %w[-e raise("EXCEPTION")])
+ assert_mruby("", /\bEXCEPTION\b.*\n\z/, false, %w[-e raise("EXCEPTION")])
end
assert('program file not found') do
- assert_mruby.("", /\A.*: Cannot open program file: .*\n\z/, false, %w[_no_exists_])
+ assert_mruby("", /\A.*: Cannot open program file: .*\n\z/, false, %w[_no_exists_])
end
assert('codegen error') do
code = "def f(#{(1..100).map{|n| "a#{n}"} * ","}); end"
- assert_mruby.("", /\Acodegen error:.*\n\z/, false, ["-e", code])
+ assert_mruby("", /\Acodegen error:.*\n\z/, false, ["-e", code])
end

Use a normal method instead of a lambda in bintest/mruby; ref #4416