[前][次][番号順一覧][スレッド一覧]

ruby-changes:59352

From: Yusuke <ko1@a...>
Date: Sat, 21 Dec 2019 10:06:54 +0900 (JST)
Subject: [ruby-changes:59352] ea405ee8ed (master): test/ruby/test_pattern_matching.rb: suppress "unused variable" warning

https://git.ruby-lang.org/ruby.git/commit/?id=ea405ee8ed

From ea405ee8ed00c03e0521ff4b852d8f3bea849243 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sat, 21 Dec 2019 10:06:14 +0900
Subject: test/ruby/test_pattern_matching.rb: suppress "unused variable"
 warning


diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb
index dc72aa0..6dbb25c 100644
--- a/test/ruby/test_pattern_matching.rb
+++ b/test/ruby/test_pattern_matching.rb
@@ -264,6 +264,7 @@ class TestPatternMatching < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L264
     assert_block do
       case 0
       in a
+        assert_equal(0, a)
         true
       in a
         flunk
@@ -471,6 +472,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L472
       [[0], C.new([0])].all? do |i|
         case i
         in *a, 0, 1
+          raise a # suppress "unused variable: a" warning
         else
           true
         end
@@ -637,6 +639,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L639
     assert_block do
       case []
       in [0, *a]
+        raise a # suppress "unused variable: a" warning
       else
         true
       end
@@ -652,6 +655,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L655
     assert_block do
       case [0]
       in [0, *a, 1]
+        raise a # suppress "unused variable: a" warning
       else
         true
       end
@@ -696,6 +700,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L700
     assert_block do
       case []
       in [0, *a]
+        raise a # suppress "unused variable: a" warning
       else
         true
       end
@@ -792,6 +797,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L797
       [{}, C.new({})].all? do |i|
         case i
         in a:
+          raise a # suppress "unused variable: a" warning
         else
           true
         end
@@ -874,6 +880,8 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L880
       [{}, C.new({})].all? do |i|
         case i
         in a:, **b
+          raise a # suppress "unused variable: a" warning
+          raise b # suppress "unused variable: b" warning
         else
           true
         end
@@ -921,6 +929,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L929
       [{a: 0}, C.new({a: 0})].all? do |i|
         case i
         in a:, **nil
+          assert_equal(0, a)
           true
         end
       end
@@ -930,6 +939,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L939
       [{a: 0, b: 1}, C.new({a: 0, b: 1})].all? do |i|
         case i
         in a:, **nil
+          assert_equal(0, a)
         else
           true
         end
@@ -1130,6 +1140,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L1140
     assert_block do
       case C.new({a: 0, b: 0, c: 0})
       in {a: 0, b:}
+        assert_equal(0, b)
         C.keys == [:a, :b]
       end
     end
@@ -1137,6 +1148,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L1148
     assert_block do
       case C.new({a: 0, b: 0, c: 0})
       in {a: 0, b:, **}
+        assert_equal(0, b)
         C.keys == [:a, :b]
       end
     end
@@ -1144,6 +1156,8 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L1156
     assert_block do
       case C.new({a: 0, b: 0, c: 0})
       in {a: 0, b:, **r}
+        assert_equal(0, b)
+        assert_equal({c: 0}, r)
         C.keys == nil
       end
     end
@@ -1158,6 +1172,7 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L1172
     assert_block do
       case C.new({a: 0, b: 0, c: 0})
       in {**r}
+        assert_equal({a: 0, b: 0, c: 0}, r)
         C.keys == nil
       end
     end
@@ -1250,6 +1265,8 @@ END https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pattern_matching.rb#L1265
       s = Struct.new(:a, :b, keyword_init: true)
       case s[a: 0, b: 1]
       in a:, c:
+        raise a # suppress "unused variable: a" warning
+        raise c # suppress "unused variable: c" warning
         flunk
       in a:, b:, c:
         flunk
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]