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

ruby-changes:26469

From: nobu <ko1@a...>
Date: Fri, 21 Dec 2012 16:36:00 +0900 (JST)
Subject: [ruby-changes:26469] nobu:r38520 (trunk): test_thread.rb: descriptive assertions

nobu	2012-12-21 16:35:49 +0900 (Fri, 21 Dec 2012)

  New Revision: 38520

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38520

  Log:
    test_thread.rb: descriptive assertions
    
    * test/ruby/test_thread.rb: (test_local_barrier),
      (test_status_and_stop_p, test_recursive_outer, test_stack_size): use
      more descriptive assertions.

  Modified files:
    trunk/test/ruby/test_thread.rb

Index: test/ruby/test_thread.rb
===================================================================
--- test/ruby/test_thread.rb	(revision 38519)
+++ test/ruby/test_thread.rb	(revision 38520)
@@ -128,7 +128,7 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L128
     $:.shift
     3.times {
       `#{EnvUtil.rubybin} #{lbtest}`
-      assert(!$?.coredump?, '[ruby-dev:30653]')
+      assert_not_predicate($?, :coredump?, '[ruby-dev:30653]')
     }
   end
 
@@ -339,14 +339,14 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L339
     sleep 0.5
 
     assert_equal(nil, a.status)
-    assert(a.stop?)
+    assert_predicate(a, :stop?)
 
     assert_equal("sleep", b.status)
-    assert(b.stop?)
+    assert_predicate(b, :stop?)
 
     assert_equal(false, c.status)
     assert_match(/^#<TestThread::Thread:.* dead>$/, c.inspect)
-    assert(c.stop?)
+    assert_predicate(c, :stop?)
 
     es1 = e.status
     es2 = e.stop?
@@ -494,7 +494,7 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L494
       raise "recursive_outer should short circuit intermediate calls"
     end
     assert_nothing_raised {arr.hash}
-    assert(obj[:visited])
+    assert(obj[:visited], "obj.hash was not called")
   end
 
   def test_thread_instance_variable
@@ -885,19 +885,23 @@ Thread.new(Thread.current) {|mth| https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L885
     h_0 = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 0, 0, false))
     h_large = eval(invoke_rec('p RubyVM::DEFAULT_PARAMS', 1024 * 1024 * 10, 1024 * 1024 * 10, false))
 
-    assert(h_default[:thread_vm_stack_size] > h_0[:thread_vm_stack_size])
-    assert(h_default[:thread_vm_stack_size] < h_large[:thread_vm_stack_size])
-    assert(h_default[:thread_machine_stack_size] >= h_0[:thread_machine_stack_size])
-    assert(h_default[:thread_machine_stack_size] <= h_large[:thread_machine_stack_size])
+    assert_operator(h_default[:thread_vm_stack_size], :>, h_0[:thread_vm_stack_size],
+                    "0 thread_vm_stack_size")
+    assert_operator(h_default[:thread_vm_stack_size], :<, h_large[:thread_vm_stack_size],
+                    "large thread_vm_stack_size")
+    assert_operator(h_default[:thread_machine_stack_size], :>=, h_0[:thread_machine_stack_size],
+                    "0 thread_machine_stack_size")
+    assert_operator(h_default[:thread_machine_stack_size], :<=, h_large[:thread_machine_stack_size],
+                    "large thread_machine_stack_size")
 
     # check VM machine stack size
     script = 'def rec; print "."; STDOUT.flush; rec; end; rec'
     size_default = invoke_rec script, nil, nil
-    assert(size_default > 0, size_default.to_s)
+    assert_operator(size_default, :>, 0, "default size")
     size_0 = invoke_rec script, 0, nil
-    assert(size_default > size_0, [size_default, size_0].inspect)
+    assert_operator(size_default, :>, size_0, "0 size")
     size_large = invoke_rec script, 1024 * 1024 * 10, nil
-    assert(size_default < size_large, [size_default, size_large].inspect)
+    assert_operator(size_default, :<, size_large, "large size")
 
     return if /mswin|mingw/ =~ RUBY_PLATFORM
 
@@ -907,8 +911,8 @@ Thread.new(Thread.current) {|mth| https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L911
     vm_stack_size = 1024 * 1024
     size_default = invoke_rec script, vm_stack_size, nil
     size_0 = invoke_rec script, vm_stack_size, 0
-    assert(size_default >= size_0, [size_default, size_0].inspect)
+    assert_operator(size_default, :>=, size_0, "0 size")
     size_large = invoke_rec script, vm_stack_size, 1024 * 1024 * 10
-    assert(size_default <= size_large, [size_default, size_large].inspect)
+    assert_operator(size_default, :<=, size_large, "large size")
   end
 end

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

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