summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/envutil.rb4
-rw-r--r--test/ruby/test_syntax.rb6
2 files changed, 5 insertions, 5 deletions
diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb
index e9a60ed5e0..dfcd0e0808 100644
--- a/test/ruby/envutil.rb
+++ b/test/ruby/envutil.rb
@@ -219,13 +219,13 @@ module Test
module Unit
module Assertions
public
- def assert_valid_syntax(code, fname = caller_locations(1, 1)[0], mesg = fname.to_s)
+ def assert_valid_syntax(code, fname = caller_locations(1, 1)[0], mesg = fname.to_s, verbose: nil)
code = code.dup.force_encoding("ascii-8bit")
code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) {
"#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n"
}
code.force_encoding(Encoding::UTF_8)
- verbose, $VERBOSE = $VERBOSE, nil
+ verbose, $VERBOSE = $VERBOSE, verbose
yield if defined?(yield)
case
when Array === fname
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 0e8a5ee478..c20f85feea 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -143,14 +143,14 @@ class TestSyntax < Test::Unit::TestCase
def test_warn_grouped_expression
bug5214 = '[ruby-core:39050]'
assert_warning("", bug5214) do
- assert_valid_syntax("foo \\\n(\n true)", "test") {$VERBOSE = true}
+ assert_valid_syntax("foo \\\n(\n true)", "test", verbose: true)
end
end
def test_warn_unreachable
assert_warning("test:3: warning: statement not reached\n") do
code = "loop do\n" "break\n" "foo\n" "end"
- assert_valid_syntax(code, "test") {$VERBOSE = true}
+ assert_valid_syntax(code, "test", verbose: true)
end
end
@@ -170,7 +170,7 @@ WARN
[:%, "string literal"],
].each do |op, syn|
assert_warning(warning % [op, syn]) do
- assert_valid_syntax("puts 1 #{op}0", "test") {$VERBOSE = true}
+ assert_valid_syntax("puts 1 #{op}0", "test", verbose: true)
end
end
end