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

ruby-changes:23502

From: nobu <ko1@a...>
Date: Mon, 7 May 2012 10:23:23 +0900 (JST)
Subject: [ruby-changes:23502] nobu:r35553 (trunk): use assert_equal, assert_match, and so on.

nobu	2012-05-07 10:23:07 +0900 (Mon, 07 May 2012)

  New Revision: 35553

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

  Log:
    use assert_equal, assert_match, and so on.
    
    * test/fileutils/fileasserts.rb: use assert_equal, assert_match, and so on.
    * test/ruby/enc/test_utf16.rb, test/ruby/enc/test_utf32.rb,
      test/ruby/test_io_m17n.rb (assert_str_equal): ditto.
    * test/rubygems/test_gem_remote_fetcher.rb
      (assert_data_from_{server,proxy}): ditto.
    * test/test_pstore.rb (test_thread_safe): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/test/fileutils/fileasserts.rb
    trunk/test/ruby/enc/test_utf16.rb
    trunk/test/ruby/enc/test_utf32.rb
    trunk/test/ruby/test_env.rb
    trunk/test/ruby/test_io_m17n.rb
    trunk/test/rubygems/test_gem_remote_fetcher.rb
    trunk/test/test_pstore.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35552)
+++ ChangeLog	(revision 35553)
@@ -1,3 +1,15 @@
+Mon May  7 10:23:04 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* test/fileutils/fileasserts.rb: use assert_equal, assert_match, and so on.
+
+	* test/ruby/enc/test_utf16.rb, test/ruby/enc/test_utf32.rb,
+	  test/ruby/test_io_m17n.rb (assert_str_equal): ditto.
+
+	* test/rubygems/test_gem_remote_fetcher.rb
+	  (assert_data_from_{server,proxy}): ditto.
+
+	* test/test_pstore.rb (test_thread_safe): ditto.
+
 Mon May  7 10:16:30 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* test/rubygems/test_gem_installer.rb (TestGemInstaller#test_dir): fix
Index: test/ruby/test_io_m17n.rb
===================================================================
--- test/ruby/test_io_m17n.rb	(revision 35552)
+++ test/ruby/test_io_m17n.rb	(revision 35553)
@@ -71,7 +71,7 @@
 #{encdump expected} expected but not equal to
 #{encdump actual}.
 EOT
-    assert_block(full_message) { expected == actual }
+    assert_equal(expected, actual, full_message)
   end
 
   def test_open_r
Index: test/ruby/enc/test_utf32.rb
===================================================================
--- test/ruby/enc/test_utf32.rb	(revision 35552)
+++ test/ruby/enc/test_utf32.rb	(revision 35553)
@@ -15,7 +15,7 @@
 #{encdump expected} expected but not equal to
 #{encdump actual}.
 EOT
-    assert_block(full_message) { expected == actual }
+    assert_equal(expected, actual, full_message)
   end
 
   def test_substr
Index: test/ruby/enc/test_utf16.rb
===================================================================
--- test/ruby/enc/test_utf16.rb	(revision 35552)
+++ test/ruby/enc/test_utf16.rb	(revision 35553)
@@ -49,7 +49,7 @@
 #{encdump expected} expected but not equal to
 #{encdump actual}.
 EOT
-    assert_block(full_message) { expected == actual }
+    assert_equal(expected, actual, full_message)
   end
 
   # tests start
Index: test/ruby/test_env.rb
===================================================================
--- test/ruby/test_env.rb	(revision 35552)
+++ test/ruby/test_env.rb	(revision 35553)
@@ -140,8 +140,7 @@
   end
 
   def test_keys
-    a = nil
-    assert_block { a = ENV.keys }
+    a = ENV.keys
     assert_kind_of(Array, a)
     a.each {|k| assert_kind_of(String, k) }
   end
@@ -151,8 +150,7 @@
   end
 
   def test_values
-    a = nil
-    assert_block { a = ENV.values }
+    a = ENV.values
     assert_kind_of(Array, a)
     a.each {|k| assert_kind_of(String, k) }
   end
Index: test/fileutils/fileasserts.rb
===================================================================
--- test/fileutils/fileasserts.rb	(revision 35552)
+++ test/fileutils/fileasserts.rb	(revision 35553)
@@ -3,17 +3,8 @@
 module Test
   module Unit
     module FileAssertions
-
-      def _wrap_assertion
-        yield
-      end
-
       def assert_same_file(from, to, message=nil)
-        _wrap_assertion {
-          assert_block("file #{from} != #{to}#{message&&': '}#{message||''}") {
-            File.read(from) == File.read(to)
-          }
-        }
+        assert_equal(File.read(from), File.read(to), "file #{from} != #{to}#{message&&': '}#{message||''}")
       end
 
       def assert_same_entry(from, to, message=nil)
@@ -28,76 +19,52 @@
       end
 
       def assert_file_exist(path, message=nil)
-        _wrap_assertion {
-          assert_block("file not exist: #{path}#{message&&': '}#{message||''}") {
-            File.exist?(path)
-          }
-        }
+        assert(File.exist?(path), "file not exist: #{path}#{message&&': '}#{message||''}")
       end
 
       def assert_file_not_exist(path, message=nil)
-        _wrap_assertion {
-          assert_block("file not exist: #{path}#{message&&': '}#{message||''}") {
-            not File.exist?(path)
-          }
-        }
+        assert(!File.exist?(path), "file exist: #{path}#{message&&': '}#{message||''}")
       end
 
       def assert_directory(path, message=nil)
-        _wrap_assertion {
-          assert_block("is not directory: #{path}#{message&&': '}#{message||''}") {
-            File.directory?(path)
-          }
-        }
+        assert(File.directory?(path), "is not directory: #{path}#{message&&': '}#{message||''}")
       end
 
       def assert_symlink(path, message=nil)
-        _wrap_assertion {
-          assert_block("is not a symlink: #{path}#{message&&': '}#{message||''}") {
-            File.symlink?(path)
-          }
-        }
+        assert(File.symlink?(path), "is not a symlink: #{path}#{message&&': '}#{message||''}")
       end
 
       def assert_not_symlink(path)
-        _wrap_assertion {
-          assert_block("is a symlink: #{path}#{message&&': '}#{message||''}") {
-            not File.symlink?(path)
-          }
-        }
+        assert(!File.symlink?(path), "is a symlink: #{path}#{message&&': '}#{message||''}")
       end
 
       def assert_equal_time(expected, actual, message=nil)
-        _wrap_assertion {
-	  expected_str = expected.to_s
-	  actual_str = actual.to_s
-	  if expected_str == actual_str
-	    expected_str << " (nsec=#{expected.nsec})"
-	    actual_str << " (nsec=#{actual.nsec})"
-	  end
-	  full_message = build_message(message, <<EOT)
+        expected_str = expected.to_s
+        actual_str = actual.to_s
+        if expected_str == actual_str
+          expected_str << " (nsec=#{expected.nsec})"
+          actual_str << " (nsec=#{actual.nsec})"
+        end
+        full_message = build_message(message, <<EOT)
 <#{expected_str}> expected but was
 <#{actual_str}>.
 EOT
-	  assert_block(full_message) { expected == actual }
-        }
+        assert_equal(expected, actual, full_message)
       end
 
       def assert_equal_timestamp(expected, actual, message=nil)
-        _wrap_assertion {
-	  expected_str = expected.to_s
-	  actual_str = actual.to_s
-	  if expected_str == actual_str
-	    expected_str << " (nsec=#{expected.nsec})"
-	    actual_str << " (nsec=#{actual.nsec})"
-	  end
-	  full_message = build_message(message, <<EOT)
+        expected_str = expected.to_s
+        actual_str = actual.to_s
+        if expected_str == actual_str
+          expected_str << " (nsec=#{expected.nsec})"
+          actual_str << " (nsec=#{actual.nsec})"
+        end
+        full_message = build_message(message, <<EOT)
 <#{expected_str}> expected but was
 <#{actual_str}>.
 EOT
-          # subsecond timestamp is not portable.
-	  assert_block(full_message) { expected.tv_sec == actual.tv_sec }
-        }
+        # subsecond timestamp is not portable.
+        assert_equal(expected.tv_sec, actual.tv_sec, full_message)
       end
 
     end
Index: test/rubygems/test_gem_remote_fetcher.rb
===================================================================
--- test/rubygems/test_gem_remote_fetcher.rb	(revision 35552)
+++ test/rubygems/test_gem_remote_fetcher.rb	(revision 35553)
@@ -818,11 +818,11 @@
   end
 
   def assert_data_from_server(data)
-    assert_block("Data is not from server") { data =~ /0\.4\.11/ }
+    assert_match(/0\.4\.11/, data, "Data is not from server")
   end
 
   def assert_data_from_proxy(data)
-    assert_block("Data is not from proxy") { data =~ /0\.4\.2/ }
+    assert_match(/0\.4\.2/, data, "Data is not from proxy")
   end
 
   class Conn
Index: test/test_pstore.rb
===================================================================
--- test/test_pstore.rb	(revision 35552)
+++ test/test_pstore.rb	(revision 35553)
@@ -84,10 +84,10 @@
           sleep 1
         end
       end
-      until flag; end
+      sleep 0.1 until flag
       @pstore.transaction {}
     end
-    assert_block do
+    begin
       pstore = PStore.new(second_file, true)
       flag = false
       Thread.new do
@@ -97,8 +97,8 @@
           sleep 1
         end
       end
-      until flag; end
-      pstore.transaction { pstore[:foo] == "bar" }
+      sleep 0.1 until flag
+      assert_equal("bar", pstore.transaction { pstore[:foo] })
     end
   ensure
     File.unlink(second_file) rescue nil

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

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