From 298258891d2f8a80f8d1eac193c6609a256a3cf0 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 7 May 2012 01:23:07 +0000 Subject: 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/fileutils/fileasserts.rb | 79 +++++++++++++------------------------------ 1 file changed, 23 insertions(+), 56 deletions(-) (limited to 'test/fileutils') diff --git a/test/fileutils/fileasserts.rb b/test/fileutils/fileasserts.rb index e8c5fa4369..0aa139fe16 100644 --- a/test/fileutils/fileasserts.rb +++ b/test/fileutils/fileasserts.rb @@ -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 @@ module Test 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, < 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, < 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 -- cgit v1.2.3