ruby-changes:58366
From: Nobuyoshi <ko1@a...>
Date: Wed, 23 Oct 2019 02:50:46 +0900 (JST)
Subject: [ruby-changes:58366] d5d5844744 (master): Use dedicated assertion methods for warning and syntax error
https://git.ruby-lang.org/ruby.git/commit/?id=d5d5844744 From d5d58447444109a75ceb86e239827f001da6214d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 23 Oct 2019 02:30:14 +0900 Subject: Use dedicated assertion methods for warning and syntax error diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index c356f68..b4b0346 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -855,32 +855,24 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L855 end def test_void_expr_stmts_value - # This test checks if void contexts are warned correctly. - # Thus, warnings MUST NOT be suppressed. - $VERBOSE = true - stderr = $stderr - $stderr = StringIO.new("") x = 1 - assert_nil eval("x; nil") - assert_nil eval("1+1; nil") - assert_nil eval("1.+(1); nil") - assert_nil eval("TestParse; nil") - assert_nil eval("::TestParse; nil") - assert_nil eval("x..x; nil") - assert_nil eval("x...x; nil") - assert_nil eval("self; nil") - assert_nil eval("nil; nil") - assert_nil eval("true; nil") - assert_nil eval("false; nil") - assert_nil eval("defined?(1); nil") + useless_use = /useless use/ + unused = /unused/ + assert_nil assert_warning(useless_use) {eval("x; nil")} + assert_nil assert_warning(useless_use) {eval("1+1; nil")} + assert_nil assert_warning('') {eval("1.+(1); nil")} + assert_nil assert_warning(useless_use) {eval("TestParse; nil")} + assert_nil assert_warning(useless_use) {eval("::TestParse; nil")} + assert_nil assert_warning(useless_use) {eval("x..x; nil")} + assert_nil assert_warning(useless_use) {eval("x...x; nil")} + assert_nil assert_warning(unused) {eval("self; nil")} + assert_nil assert_warning(unused) {eval("nil; nil")} + assert_nil assert_warning(unused) {eval("true; nil")} + assert_nil assert_warning(unused) {eval("false; nil")} + assert_nil assert_warning(useless_use) {eval("defined?(1); nil")} assert_equal 1, x - assert_raise(SyntaxError) do - eval %q(1; next; 2) - end - - assert_equal(13, $stderr.string.lines.to_a.size) - $stderr = stderr + assert_syntax_error("1; next; 2", /Invalid next/) end def test_assign_in_conditional -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/