From 68735d12614ef72b620736a5cd3052fb79445483 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Tue, 8 Jan 2019 20:31:29 +0900 Subject: Fix dump/load float leteral evaluate to infinity Example: # example.rb p(2e308) p(-2e308) Good: $ bin/mruby example.rb inf -inf Bad: $ bin/mrbc example.rb $ bin/mruby -b example.mrb 0 -0 Cause: Float infinity representation is `inf` on dump and it is converted by corresponding `String#to_f` on load. Treatment: - Introduce new representations (`i`: +infinity, `I`: -infinity) - Allow old representations (`inf`, `-inf`, `infinity`, `-infinity`) too - Raise error for unknown representations (use corresponding `Kernel#Float`) --- mrbgems/mruby-bin-mruby/bintest/mruby.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mrbgems/mruby-bin-mruby/bintest/mruby.rb') diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb index a7fb63fa2..f3c7d8761 100644 --- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb +++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb @@ -31,6 +31,13 @@ assert '$0 value' do assert_equal '"-e"', `#{cmd('mruby')} -e #{shellquote('p $0')}`.chomp end +assert('float literal') do + script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb') + File.write script.path, 'p [3.21, 2e308.infinite?, -2e308.infinite?]' + system "#{cmd('mrbc')} -g -o #{bin.path} #{script.path}" + assert_equal "[3.21, 1, -1]", `#{cmd('mruby')} -b #{bin.path}`.chomp! +end + assert '__END__', '8.6' do script = Tempfile.new('test.rb') -- cgit v1.2.3 From 0740595f857d7c4a7420e7b6a68f307802561a1b Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Wed, 9 Jan 2019 20:00:17 +0900 Subject: Change the order of "expected" and "actual" in test --- mrbgems/mruby-bin-mruby/bintest/mruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mrbgems/mruby-bin-mruby/bintest/mruby.rb') diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb index f3c7d8761..e8d1510f7 100644 --- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb +++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb @@ -12,7 +12,7 @@ assert('regression for #1572') do File.write script.path, 'p "ok"' system "#{cmd('mrbc')} -g -o #{bin.path} #{script.path}" o = `#{cmd('mruby')} -b #{bin.path}`.strip - assert_equal o, '"ok"' + assert_equal '"ok"', o end assert '$0 value' do -- cgit v1.2.3 From 9bd17226d5cc9e36937497664886d05d527bfd19 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Tue, 30 Apr 2019 16:35:47 +0900 Subject: Refine error message output for `mruby` command - Write message to stderr instead of stdout. - Avoid duplicate message output (`SyntaxError`, `ScriptError` etc). - Refine invalid option message. - Suppress redundant usage output. - Fix some incorrect exit code. --- mrbgems/mruby-bin-mruby/bintest/mruby.rb | 51 ++++++++++++++++++++++++++--- mrbgems/mruby-bin-mruby/tools/mruby/mruby.c | 39 ++++++++-------------- 2 files changed, 60 insertions(+), 30 deletions(-) (limited to 'mrbgems/mruby-bin-mruby/bintest/mruby.rb') diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb index e8d1510f7..1dced07f9 100644 --- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb +++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb @@ -1,10 +1,16 @@ require 'tempfile' +require 'open3' + +assert_mruby = ->(exp_out_pattern, exp_err_pattern, exp_success, args) do + out, err, stat = Open3.capture3(cmd("mruby"), *args) + assert_match(exp_out_pattern, out, "standard output") + assert_match(exp_err_pattern, err, "standard error") + assert_equal(exp_success, stat.success?, "exit success?") +end assert('regression for #1564') do - o = `#{cmd('mruby')} -e #{shellquote('<<')} 2>&1` - assert_include o, "-e:1:2: syntax error" - o = `#{cmd('mruby')} -e #{shellquote('<<-')} 2>&1` - assert_include o, "-e:1:3: syntax error" + assert_mruby.("", "-e:1:2: syntax error, *", false, %w[-e <<]) + assert_mruby.("", "-e:1:3: syntax error, *", false, %w[-e <<-]) end assert('regression for #1572') do @@ -66,6 +72,11 @@ RUBY assert_equal 0, $?.exitstatus end +assert('mruby -c option') do + assert_mruby.("Syntax OK\n", "", true, ["-c", "-e", "p 1"]) + assert_mruby.("", "-e:1:7: syntax error, *", false, ["-c", "-e", "p 1; 1."]) +end + assert('mruby -d option') do o = `#{cmd('mruby')} -e #{shellquote('p $DEBUG')}` assert_equal "false\n", o @@ -73,6 +84,14 @@ assert('mruby -d option') do assert_equal "true\n", o end +assert('mruby -e option (no code specified)') do + assert_mruby.("", "* No code specified for -e\n", false, %w[-e]) +end + +assert('mruby -h option') do + assert_mruby.("Usage: *mruby*", "", true, %w[-h]) +end + assert('mruby -r option') do lib = Tempfile.new('lib.rb') lib.write < #include -#ifdef MRB_DISABLE_STDIO -static void -p(mrb_state *mrb, mrb_value obj) -{ - mrb_value val = mrb_inspect(mrb, obj); - - fwrite(RSTRING_PTR(val), RSTRING_LEN(val), 1, stdout); - putc('\n', stdout); -} -#else -#define p(mrb,obj) mrb_p(mrb,obj) -#endif - struct _args { FILE *rfp; char* cmdline; @@ -119,14 +106,17 @@ append_cmdline: } } else { - printf("%s: No code specified for -e\n", *origargv); - return EXIT_SUCCESS; + fprintf(stderr, "%s: No code specified for -e\n", *origargv); + return EXIT_FAILURE; } break; + case 'h': + usage(*origargv); + exit(EXIT_SUCCESS); case 'r': if (!item[0]) { if (argc <= 1) { - printf("%s: No library specified for -r\n", *origargv); + fprintf(stderr, "%s: No library specified for -r\n", *origargv); return EXIT_FAILURE; } argc--; argv++; @@ -158,6 +148,7 @@ append_cmdline: exit(EXIT_SUCCESS); } default: + fprintf(stderr, "%s: invalid option %s (-h will show valid options)\n", *origargv, *argv); return EXIT_FAILURE; } } @@ -167,7 +158,7 @@ append_cmdline: else { args->rfp = fopen(argv[0], args->mrbfile ? "rb" : "r"); if (args->rfp == NULL) { - printf("%s: Cannot open program file. (%s)\n", *origargv, *argv); + fprintf(stderr, "%s: Cannot open program file. (%s)\n", *origargv, *argv); return EXIT_FAILURE; } args->fname = TRUE; @@ -212,14 +203,13 @@ main(int argc, char **argv) mrb_sym zero_sym; if (mrb == NULL) { - fputs("Invalid mrb_state, exiting mruby\n", stderr); + fprintf(stderr, "%s: Invalid mrb_state, exiting mruby\n", *argv); return EXIT_FAILURE; } n = parse_args(mrb, argc, argv, &args); if (n == EXIT_FAILURE || (args.cmdline == NULL && args.rfp == NULL)) { cleanup(mrb, &args); - usage(argv[0]); return n; } else { @@ -258,7 +248,7 @@ main(int argc, char **argv) for (i = 0; i < args.libc; i++) { FILE *lfp = fopen(args.libv[i], args.mrbfile ? "rb" : "r"); if (lfp == NULL) { - printf("Cannot open library file: %s\n", args.libv[i]); + fprintf(stderr, "%s: Cannot open library file: %s\n", *argv, args.libv[i]); mrbc_context_free(mrb, c); cleanup(mrb, &args); return EXIT_FAILURE; @@ -289,13 +279,10 @@ main(int argc, char **argv) mrb_gc_arena_restore(mrb, ai); mrbc_context_free(mrb, c); if (mrb->exc) { - if (mrb_undef_p(v)) { - mrb_p(mrb, mrb_obj_value(mrb->exc)); - } - else { + if (!mrb_undef_p(v)) { mrb_print_error(mrb); } - n = -1; + n = EXIT_FAILURE; } else if (args.check_syntax) { printf("Syntax OK\n"); @@ -303,5 +290,5 @@ main(int argc, char **argv) } cleanup(mrb, &args); - return n == 0 ? EXIT_SUCCESS : EXIT_FAILURE; + return n; } -- cgit v1.2.3 From 2a94bf8fbd9afb49e1c2b83126f5952b2864d781 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Wed, 1 May 2019 16:49:56 +0900 Subject: Small fix in `mruby-bin-mruby` - Modify some error messages for consistency. - Add test for codegen error. - Use regular expression for error message matching in test. --- mrbgems/mruby-bin-mruby/bintest/mruby.rb | 33 +++++++++++++++++------------ mrbgems/mruby-bin-mruby/tools/mruby/mruby.c | 4 ++-- 2 files changed, 21 insertions(+), 16 deletions(-) (limited to 'mrbgems/mruby-bin-mruby/bintest/mruby.rb') diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb index 1dced07f9..d1262254b 100644 --- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb +++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb @@ -1,16 +1,16 @@ require 'tempfile' require 'open3' -assert_mruby = ->(exp_out_pattern, exp_err_pattern, exp_success, args) do +assert_mruby = ->(exp_out, exp_err, exp_success, args) do out, err, stat = Open3.capture3(cmd("mruby"), *args) - assert_match(exp_out_pattern, out, "standard output") - assert_match(exp_err_pattern, err, "standard error") + assert_operator(exp_out, :===, out, "standard output") + assert_operator(exp_err, :===, err, "standard error") assert_equal(exp_success, stat.success?, "exit success?") end assert('regression for #1564') do - assert_mruby.("", "-e:1:2: syntax error, *", false, %w[-e <<]) - assert_mruby.("", "-e:1:3: syntax error, *", 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 @@ -74,7 +74,7 @@ end assert('mruby -c option') do assert_mruby.("Syntax OK\n", "", true, ["-c", "-e", "p 1"]) - assert_mruby.("", "-e:1:7: syntax error, *", false, ["-c", "-e", "p 1; 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.("", "* No code specified for -e\n", false, %w[-e]) + assert_mruby.("", /\A.*: No code specified for -e\n\z/, false, %w[-e]) end assert('mruby -h option') do - assert_mruby.("Usage: *mruby*", "", true, %w[-h]) + assert_mruby.(/\AUsage: #{Regexp.escape cmd("mruby")} .*/m, "", true, %w[-h]) end assert('mruby -r option') do @@ -116,25 +116,30 @@ EOS end assert('mruby -r option (no library specified)') do - assert_mruby.("", "*: No library specified for -r\n", 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.("", "*: Cannot open library file: *", 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.("", "*: invalid option -1 *", false, %w[-1]) + assert_mruby.("", /\A.*: invalid option -1 .*\n\z/, false, %w[-1]) end assert('mruby invalid long option') do - assert_mruby.("", "*: invalid option --longopt *", false, %w[--longopt]) + assert_mruby.("", /\A.*: invalid option --longopt .*\n\z/, false, %w[--longopt]) end assert('unhandled exception') do - assert_mruby.("", "* EXCEPTION!*", 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.("", "*: Cannot open program file*", 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]) end diff --git a/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c b/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c index c96365c9f..29ab4c17c 100644 --- a/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +++ b/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c @@ -158,7 +158,7 @@ append_cmdline: else { args->rfp = fopen(argv[0], args->mrbfile ? "rb" : "r"); if (args->rfp == NULL) { - fprintf(stderr, "%s: Cannot open program file. (%s)\n", *origargv, *argv); + fprintf(stderr, "%s: Cannot open program file: %s\n", *origargv, *argv); return EXIT_FAILURE; } args->fname = TRUE; @@ -285,7 +285,7 @@ main(int argc, char **argv) n = EXIT_FAILURE; } else if (args.check_syntax) { - printf("Syntax OK\n"); + puts("Syntax OK"); } } cleanup(mrb, &args); -- cgit v1.2.3 From 35319bed01d58c785f73ce03e67d4e58be30f4b5 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Thu, 2 May 2019 23:03:38 +0900 Subject: Use a normal method instead of a lambda in bintest/mruby; ref #4416 --- mrbgems/mruby-bin-mruby/bintest/mruby.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'mrbgems/mruby-bin-mruby/bintest/mruby.rb') diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb index d1262254b..09350ff49 100644 --- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb +++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb @@ -1,7 +1,7 @@ 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 -- cgit v1.2.3 From a215292b6ad4315a5a0edef49a1df65e3f27b46a Mon Sep 17 00:00:00 2001 From: dearblue Date: Fri, 28 Jun 2019 23:13:29 +0900 Subject: Use nested `assert` --- mrbgems/mruby-bin-mruby/bintest/mruby.rb | 8 +++++--- mrbgems/mruby-complex/test/complex.rb | 6 ++++-- mrbgems/mruby-io/test/io.rb | 32 +++++++++++++++++--------------- mrbgems/mruby-pack/test/pack.rb | 6 ++++-- mrbgems/mruby-rational/test/rational.rb | 20 ++++++++++++-------- 5 files changed, 42 insertions(+), 30 deletions(-) (limited to 'mrbgems/mruby-bin-mruby/bintest/mruby.rb') diff --git a/mrbgems/mruby-bin-mruby/bintest/mruby.rb b/mrbgems/mruby-bin-mruby/bintest/mruby.rb index 09350ff49..5dbbc5592 100644 --- a/mrbgems/mruby-bin-mruby/bintest/mruby.rb +++ b/mrbgems/mruby-bin-mruby/bintest/mruby.rb @@ -3,9 +3,11 @@ require 'open3' 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") - assert_equal(exp_success, stat.success?, "exit success?") + assert do + assert_operator(exp_out, :===, out, "standard output") + assert_operator(exp_err, :===, err, "standard error") + assert_equal(exp_success, stat.success?, "exit success?") + end end assert('regression for #1564') do diff --git a/mrbgems/mruby-complex/test/complex.rb b/mrbgems/mruby-complex/test/complex.rb index 6996eb214..ab882664e 100644 --- a/mrbgems/mruby-complex/test/complex.rb +++ b/mrbgems/mruby-complex/test/complex.rb @@ -1,6 +1,8 @@ def assert_complex(real, exp) - assert_float real.real, exp.real - assert_float real.imaginary, exp.imaginary + assert do + assert_float real.real, exp.real + assert_float real.imaginary, exp.imaginary + end end assert 'Complex' do diff --git a/mrbgems/mruby-io/test/io.rb b/mrbgems/mruby-io/test/io.rb index ef0b49643..1491a4cfe 100644 --- a/mrbgems/mruby-io/test/io.rb +++ b/mrbgems/mruby-io/test/io.rb @@ -5,24 +5,26 @@ MRubyIOTestUtil.io_test_setup $cr, $crlf, $cmd = MRubyIOTestUtil.win? ? [1, "\r\n", "cmd /c "] : [0, "\n", ""] def assert_io_open(meth) - fd = IO.sysopen($mrbtest_io_rfname) - assert_equal Fixnum, fd.class - io1 = IO.__send__(meth, fd) - begin - assert_equal IO, io1.class - assert_equal $mrbtest_io_msg, io1.read - ensure - io1.close - end + assert do + fd = IO.sysopen($mrbtest_io_rfname) + assert_equal Fixnum, fd.class + io1 = IO.__send__(meth, fd) + begin + assert_equal IO, io1.class + assert_equal $mrbtest_io_msg, io1.read + ensure + io1.close + end - io2 = IO.__send__(meth, IO.sysopen($mrbtest_io_rfname))do |io| - if meth == :open - assert_equal $mrbtest_io_msg, io.read - else - flunk "IO.#{meth} does not take block" + io2 = IO.__send__(meth, IO.sysopen($mrbtest_io_rfname))do |io| + if meth == :open + assert_equal $mrbtest_io_msg, io.read + else + flunk "IO.#{meth} does not take block" + end end + io2.close unless meth == :open end - io2.close unless meth == :open end assert('IO.class', '15.2.20') do diff --git a/mrbgems/mruby-pack/test/pack.rb b/mrbgems/mruby-pack/test/pack.rb index 110aee5db..eb24e8d1f 100644 --- a/mrbgems/mruby-pack/test/pack.rb +++ b/mrbgems/mruby-pack/test/pack.rb @@ -2,8 +2,10 @@ PACK_IS_LITTLE_ENDIAN = "\x01\00".unpack('S')[0] == 0x01 def assert_pack tmpl, packed, unpacked t = tmpl.inspect - assert_equal packed, unpacked.pack(tmpl), "#{unpacked.inspect}.pack(#{t})" - assert_equal unpacked, packed.unpack(tmpl), "#{packed.inspect}.unpack(#{t})" + assert do + assert_equal packed, unpacked.pack(tmpl), "#{unpacked.inspect}.pack(#{t})" + assert_equal unpacked, packed.unpack(tmpl), "#{packed.inspect}.unpack(#{t})" + end end # pack & unpack 'm' (base64) diff --git a/mrbgems/mruby-rational/test/rational.rb b/mrbgems/mruby-rational/test/rational.rb index 5e9d9ea48..11737034b 100644 --- a/mrbgems/mruby-rational/test/rational.rb +++ b/mrbgems/mruby-rational/test/rational.rb @@ -23,17 +23,21 @@ class ComplexLikeNumeric < UserDefinedNumeric end def assert_rational(exp, real) - assert_float exp.numerator, real.numerator - assert_float exp.denominator, real.denominator + assert do + assert_float exp.numerator, real.numerator + assert_float exp.denominator, real.denominator + end end def assert_equal_rational(exp, o1, o2) - if exp - assert_operator(o1, :==, o2) - assert_not_operator(o1, :!=, o2) - else - assert_not_operator(o1, :==, o2) - assert_operator(o1, :!=, o2) + assert do + if exp + assert_operator(o1, :==, o2) + assert_not_operator(o1, :!=, o2) + else + assert_not_operator(o1, :==, o2) + assert_operator(o1, :!=, o2) + end end end -- cgit v1.2.3