summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2024-09-17 22:32:09 +0900
committerYusuke Endoh <mame@ruby-lang.org>2024-09-17 22:52:25 +0900
commitfd5e583990330f2d84d05d1ae1ceea2a472b6352 (patch)
tree697005a9bea56fdd41ea681753c561fc7487fa45
parentcf063c008fd988def961fdddf7616e52345af3f9 (diff)
Prevent two warnings
``` /home/chkbuild/chkbuild/tmp/build/20240917T123003Z/ruby/test/ruby/test_case.rb:73: warning: 'when' clause on line 73 duplicates 'when' clause on line 73 and is ignored /home/chkbuild/chkbuild/tmp/build/20240917T123003Z/ruby/test/ruby/test_syntax.rb:333: warning: key :k1 is duplicated and overwritten on line 333 ```
-rw-r--r--test/ruby/test_case.rb11
-rw-r--r--test/ruby/test_syntax.rb7
2 files changed, 14 insertions, 4 deletions
diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb
index 4a0f1bf78d..3725fb49bb 100644
--- a/test/ruby/test_case.rb
+++ b/test/ruby/test_case.rb
@@ -68,10 +68,15 @@ class TestCase < Test::Unit::TestCase
assert(false)
end
- assert_raise(NameError) do
- case
- when false, *x, false
+ begin
+ verbose_bak, $VERBOSE = $VERBOSE, nil
+ assert_raise(NameError) do
+ case
+ when false, *x, false
+ end
end
+ ensure
+ $VERBOSE = verbose_bak
end
end
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index fe6fa30e02..4ed28320b3 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -330,7 +330,12 @@ class TestSyntax < Test::Unit::TestCase
bug10315 = '[ruby-core:65368] [Bug #10315]'
o = KW2.new
- assert_equal([23, 2], o.kw(**{k1: 22}, **{k1: 23}), bug10315)
+ begin
+ verbose_bak, $VERBOSE = $VERBOSE, nil
+ assert_equal([23, 2], eval("o.kw(**{k1: 22}, **{k1: 23}"), bug10315)
+ ensure
+ $VERBOSE = verbose_bak
+ end
h = {k3: 31}
assert_raise(ArgumentError) {o.kw(**h)}