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

ruby-changes:53718

From: kazu <ko1@a...>
Date: Fri, 23 Nov 2018 20:00:05 +0900 (JST)
Subject: [ruby-changes:53718] kazu:r65934 (trunk): test/ruby/test_thread.rb: use safe navigation operator.

kazu	2018-11-23 19:59:59 +0900 (Fri, 23 Nov 2018)

  New Revision: 65934

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65934

  Log:
    test/ruby/test_thread.rb: use safe navigation operator.

  Modified files:
    trunk/test/ruby/test_thread.rb
Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 65933)
+++ test/ruby/test_thread.rb	(revision 65934)
@@ -226,9 +226,9 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L226
     assert_equal(t1, t3.value)
 
   ensure
-    t1.kill if t1
-    t2.kill if t2
-    t3.kill if t3
+    t1&.kill
+    t2&.kill
+    t3&.kill
   end
 
   { 'FIXNUM_MAX' => RbConfig::LIMITS['FIXNUM_MAX'],
@@ -629,7 +629,8 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L629
     end
     Thread.pass until t.stop?
     assert_predicate(t, :alive?)
-    t.kill
+  ensure
+    t&.kill
   end
 
   def test_mutex_deadlock
@@ -1111,7 +1112,7 @@ q.pop https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L1112
       Thread.pass until mutex.locked?
       assert_equal(mutex.owned?, false)
     ensure
-      th.kill if th
+      th&.kill
     end
   end
 

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

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