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
This commit is contained in:
parent
b5ba059a0b
commit
298258891d
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
Mon May 7 10:23:04 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Mon May 7 10:16:30 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* test/rubygems/test_gem_installer.rb (TestGemInstaller#test_dir): fix
|
* test/rubygems/test_gem_installer.rb (TestGemInstaller#test_dir): fix
|
||||||
|
@ -3,17 +3,8 @@
|
|||||||
module Test
|
module Test
|
||||||
module Unit
|
module Unit
|
||||||
module FileAssertions
|
module FileAssertions
|
||||||
|
|
||||||
def _wrap_assertion
|
|
||||||
yield
|
|
||||||
end
|
|
||||||
|
|
||||||
def assert_same_file(from, to, message=nil)
|
def assert_same_file(from, to, message=nil)
|
||||||
_wrap_assertion {
|
assert_equal(File.read(from), File.read(to), "file #{from} != #{to}#{message&&': '}#{message||''}")
|
||||||
assert_block("file #{from} != #{to}#{message&&': '}#{message||''}") {
|
|
||||||
File.read(from) == File.read(to)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_same_entry(from, to, message=nil)
|
def assert_same_entry(from, to, message=nil)
|
||||||
@ -28,47 +19,26 @@ module Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assert_file_exist(path, message=nil)
|
def assert_file_exist(path, message=nil)
|
||||||
_wrap_assertion {
|
assert(File.exist?(path), "file not exist: #{path}#{message&&': '}#{message||''}")
|
||||||
assert_block("file not exist: #{path}#{message&&': '}#{message||''}") {
|
|
||||||
File.exist?(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_file_not_exist(path, message=nil)
|
def assert_file_not_exist(path, message=nil)
|
||||||
_wrap_assertion {
|
assert(!File.exist?(path), "file exist: #{path}#{message&&': '}#{message||''}")
|
||||||
assert_block("file not exist: #{path}#{message&&': '}#{message||''}") {
|
|
||||||
not File.exist?(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_directory(path, message=nil)
|
def assert_directory(path, message=nil)
|
||||||
_wrap_assertion {
|
assert(File.directory?(path), "is not directory: #{path}#{message&&': '}#{message||''}")
|
||||||
assert_block("is not directory: #{path}#{message&&': '}#{message||''}") {
|
|
||||||
File.directory?(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_symlink(path, message=nil)
|
def assert_symlink(path, message=nil)
|
||||||
_wrap_assertion {
|
assert(File.symlink?(path), "is not a symlink: #{path}#{message&&': '}#{message||''}")
|
||||||
assert_block("is not a symlink: #{path}#{message&&': '}#{message||''}") {
|
|
||||||
File.symlink?(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_not_symlink(path)
|
def assert_not_symlink(path)
|
||||||
_wrap_assertion {
|
assert(!File.symlink?(path), "is a symlink: #{path}#{message&&': '}#{message||''}")
|
||||||
assert_block("is a symlink: #{path}#{message&&': '}#{message||''}") {
|
|
||||||
not File.symlink?(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_equal_time(expected, actual, message=nil)
|
def assert_equal_time(expected, actual, message=nil)
|
||||||
_wrap_assertion {
|
|
||||||
expected_str = expected.to_s
|
expected_str = expected.to_s
|
||||||
actual_str = actual.to_s
|
actual_str = actual.to_s
|
||||||
if expected_str == actual_str
|
if expected_str == actual_str
|
||||||
@ -79,12 +49,10 @@ module Test
|
|||||||
<#{expected_str}> expected but was
|
<#{expected_str}> expected but was
|
||||||
<#{actual_str}>.
|
<#{actual_str}>.
|
||||||
EOT
|
EOT
|
||||||
assert_block(full_message) { expected == actual }
|
assert_equal(expected, actual, full_message)
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_equal_timestamp(expected, actual, message=nil)
|
def assert_equal_timestamp(expected, actual, message=nil)
|
||||||
_wrap_assertion {
|
|
||||||
expected_str = expected.to_s
|
expected_str = expected.to_s
|
||||||
actual_str = actual.to_s
|
actual_str = actual.to_s
|
||||||
if expected_str == actual_str
|
if expected_str == actual_str
|
||||||
@ -96,8 +64,7 @@ EOT
|
|||||||
<#{actual_str}>.
|
<#{actual_str}>.
|
||||||
EOT
|
EOT
|
||||||
# subsecond timestamp is not portable.
|
# subsecond timestamp is not portable.
|
||||||
assert_block(full_message) { expected.tv_sec == actual.tv_sec }
|
assert_equal(expected.tv_sec, actual.tv_sec, full_message)
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -49,7 +49,7 @@ class TestUTF16 < Test::Unit::TestCase
|
|||||||
#{encdump expected} expected but not equal to
|
#{encdump expected} expected but not equal to
|
||||||
#{encdump actual}.
|
#{encdump actual}.
|
||||||
EOT
|
EOT
|
||||||
assert_block(full_message) { expected == actual }
|
assert_equal(expected, actual, full_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
# tests start
|
# tests start
|
||||||
|
@ -15,7 +15,7 @@ class TestUTF32 < Test::Unit::TestCase
|
|||||||
#{encdump expected} expected but not equal to
|
#{encdump expected} expected but not equal to
|
||||||
#{encdump actual}.
|
#{encdump actual}.
|
||||||
EOT
|
EOT
|
||||||
assert_block(full_message) { expected == actual }
|
assert_equal(expected, actual, full_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_substr
|
def test_substr
|
||||||
|
@ -140,8 +140,7 @@ class TestEnv < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_keys
|
def test_keys
|
||||||
a = nil
|
a = ENV.keys
|
||||||
assert_block { a = ENV.keys }
|
|
||||||
assert_kind_of(Array, a)
|
assert_kind_of(Array, a)
|
||||||
a.each {|k| assert_kind_of(String, k) }
|
a.each {|k| assert_kind_of(String, k) }
|
||||||
end
|
end
|
||||||
@ -151,8 +150,7 @@ class TestEnv < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_values
|
def test_values
|
||||||
a = nil
|
a = ENV.values
|
||||||
assert_block { a = ENV.values }
|
|
||||||
assert_kind_of(Array, a)
|
assert_kind_of(Array, a)
|
||||||
a.each {|k| assert_kind_of(String, k) }
|
a.each {|k| assert_kind_of(String, k) }
|
||||||
end
|
end
|
||||||
|
@ -71,7 +71,7 @@ class TestIO_M17N < Test::Unit::TestCase
|
|||||||
#{encdump expected} expected but not equal to
|
#{encdump expected} expected but not equal to
|
||||||
#{encdump actual}.
|
#{encdump actual}.
|
||||||
EOT
|
EOT
|
||||||
assert_block(full_message) { expected == actual }
|
assert_equal(expected, actual, full_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_open_r
|
def test_open_r
|
||||||
|
@ -818,11 +818,11 @@ gems:
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assert_data_from_server(data)
|
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
|
end
|
||||||
|
|
||||||
def assert_data_from_proxy(data)
|
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
|
end
|
||||||
|
|
||||||
class Conn
|
class Conn
|
||||||
|
@ -84,10 +84,10 @@ class PStoreTest < Test::Unit::TestCase
|
|||||||
sleep 1
|
sleep 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
until flag; end
|
sleep 0.1 until flag
|
||||||
@pstore.transaction {}
|
@pstore.transaction {}
|
||||||
end
|
end
|
||||||
assert_block do
|
begin
|
||||||
pstore = PStore.new(second_file, true)
|
pstore = PStore.new(second_file, true)
|
||||||
flag = false
|
flag = false
|
||||||
Thread.new do
|
Thread.new do
|
||||||
@ -97,8 +97,8 @@ class PStoreTest < Test::Unit::TestCase
|
|||||||
sleep 1
|
sleep 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
until flag; end
|
sleep 0.1 until flag
|
||||||
pstore.transaction { pstore[:foo] == "bar" }
|
assert_equal("bar", pstore.transaction { pstore[:foo] })
|
||||||
end
|
end
|
||||||
ensure
|
ensure
|
||||||
File.unlink(second_file) rescue nil
|
File.unlink(second_file) rescue nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user