1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/test/unit/assertions.rb (Test::Unit::Assertions#assert):

use more descriptive assertions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-04-29 05:46:04 +00:00
parent e1cc514073
commit 921b2d1cfb
10 changed files with 25 additions and 21 deletions

View file

@ -1,4 +1,7 @@
Thu Apr 29 14:33:39 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
Thu Apr 29 14:46:00 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/test/unit/assertions.rb (Test::Unit::Assertions#assert):
use more descriptive assertions.
* test/ruby: fixed nonsense assertions.

View file

@ -290,8 +290,8 @@ class TestBignum < Test::Unit::TestCase
def test_pow
assert_equal(1.0, T32 ** 0.0)
assert_equal(1.0 / T32, T32 ** -1)
assert((T32 ** T32).infinite?)
assert((T32 ** (2**30-1)).infinite?)
assert_equal(1, (T32 ** T32).infinite?)
assert_equal(1, (T32 ** (2**30-1)).infinite?)
### rational changes the behavior of Bignum#**
#assert_raise(TypeError) { T32**"foo" }

View file

@ -52,8 +52,8 @@ class TestEncoding < Test::Unit::TestCase
end
def test_replicate
assert(Encoding::UTF_8.replicate('UTF-8-ANOTHER'))
assert(Encoding::ISO_2022_JP.replicate('ISO-2022-JP-ANOTHER'))
assert_instance_of(Encoding, Encoding::UTF_8.replicate('UTF-8-ANOTHER'))
assert_instance_of(Encoding, Encoding::ISO_2022_JP.replicate('ISO-2022-JP-ANOTHER'))
bug3127 = '[ruby-dev:40954]'
assert_raise(TypeError, bug3127) {Encoding::UTF_8.replicate(0)}
assert_raise(ArgumentError, bug3127) {Encoding::UTF_8.replicate("\0")}

View file

@ -187,7 +187,7 @@ class TestFixnum < Test::Unit::TestCase
assert_equal(4, 2**((2**32).coerce(2).first))
assert_equal(2, 4**0.5)
assert_equal(0, 0**0.5)
assert((0**-1.0).infinite?)
assert_equal(1, (0**-1.0).infinite?)
### rational changes the behavior of Fixnum#**
#assert_raise(TypeError) { 1 ** nil }
assert_raise(TypeError, NoMethodError) { 1 ** nil }

View file

@ -419,10 +419,10 @@ class TestFloat < Test::Unit::TestCase
def test_Float
assert_in_delta(0.125, Float("0.1_2_5"), 0.00001)
assert_in_delta(0.125, "0.1_2_5__".to_f, 0.00001)
assert(Float(([1] * 10000).join).infinite?)
assert_equal(1, Float(([1] * 10000).join).infinite?)
assert(!Float(([1] * 10000).join("_")).infinite?) # is it really OK?
assert_raise(ArgumentError) { Float("1.0\x001") }
assert(Float("1e10_00").infinite?)
assert_equal(1, Float("1e10_00").infinite?)
assert_raise(TypeError) { Float(nil) }
o = Object.new
def o.to_f; inf = Float::INFINITY; inf/inf; end

View file

@ -814,7 +814,7 @@ class TestIO < Test::Unit::TestCase
def test_inspect
with_pipe do |r, w|
assert(r.inspect =~ /^#<IO:fd \d+>$/)
assert_match(/^#<IO:fd \d+>$/, r.inspect)
assert_raise(SecurityError) do
safe_4 { r.inspect }
end

View file

@ -567,7 +567,7 @@ class TestPack < Test::Unit::TestCase
end
def test_pack_p2
assert([nil].pack("p") =~ /\A\0*\Z/)
assert_match(/\A\0*\Z/, [nil].pack("p"))
end
def test_pack_unpack_w

View file

@ -637,8 +637,8 @@ class TestRegexp < Test::Unit::TestCase
check(/\u3042\d/, ["\u30421", "\u30422"])
# CClassTable cache test
assert(/\u3042\d/.match("\u30421"))
assert(/\u3042\d/.match("\u30422"))
assert_match(/\u3042\d/, "\u30421")
assert_match(/\u3042\d/, "\u30422")
end
def test_char_class

View file

@ -278,7 +278,8 @@ class TestSprintf < Test::Unit::TestCase
end
def test_rb_sprintf
assert(T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.new.inspect =~ /^#<TestSprintf::T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789:0x[0-9a-f]+>$/)
assert_match(/^#<TestSprintf::T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789:0x[0-9a-f]+>$/,
T012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789.new.inspect)
end
def test_negative_hex

View file

@ -37,8 +37,8 @@ END
$x.gsub!(/((.|\n)*?)B((.|\n)*?)D/m ,'\1\3')
assert_equal("AC\nAC\n", $x)
assert("foobar" =~ /foo(?=(bar)|(baz))/)
assert("foobaz" =~ /foo(?=(bar)|(baz))/)
assert_match(/foo(?=(bar)|(baz))/, "foobar")
assert_match(/foo(?=(bar)|(baz))/, "foobaz")
$foo = "abc"
assert_equal("abc = abc", "#$foo = abc")