summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2024-04-04 13:24:09 +0900
committerYusuke Endoh <mame@ruby-lang.org>2024-04-04 13:29:41 +0900
commitcb30c3d2b3385aaa2ac4f8fd2c0d674a15b300d8 (patch)
treebe33649ad3b905364078e7674b53795450eed739 /test/ruby
parentfc67091fc8dc4c7122499cd0d287cd34ff01bf30 (diff)
Prevent "assigned but unused variable" warnings
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_call.rb6
-rw-r--r--test/ruby/test_parse.rb4
2 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb
index d5fe9ce320..a52b75c267 100644
--- a/test/ruby/test_call.rb
+++ b/test/ruby/test_call.rb
@@ -133,6 +133,9 @@ class TestCall < Test::Unit::TestCase
kw = {}
b = lambda{}
+ # Prevent "assigned but unused variable" warnings
+ _ = [h, a, kw, b]
+
message = /keyword arg given in index/
# +=, without block, non-popped
@@ -294,6 +297,9 @@ class TestCall < Test::Unit::TestCase
a = []
kw = {}
+ # Prevent "assigned but unused variable" warnings
+ _ = [h, a, kw]
+
assert_syntax_error(%q{h[*a, 2, b: 5, **kw] += 1}, message)
end
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index e365c39def..9048f55a85 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -498,6 +498,10 @@ class TestParse < Test::Unit::TestCase
t = Object.new
a = []
blk = proc {|x| a << x }
+
+ # Prevent an "assigned but unused variable" warning
+ _ = blk
+
def t.[](_)
yield(:aref)
nil