refine assertions

* test/ruby/test_complex.rb, test/ruby/test_rational.rb: refine
  assertions for descriptive messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-10-24 01:34:06 +00:00
parent d2d44828a3
commit 3bda73868f
2 changed files with 62 additions and 62 deletions

View File

@ -41,10 +41,10 @@ class Complex_Test < Test::Unit::TestCase
c2 = Complex(0) c2 = Complex(0)
c3 = Complex(1) c3 = Complex(1)
assert_equal(true, c.eql?(c2)) assert_operator(c, :eql?, c2)
assert_equal(false, c.eql?(c3)) assert_not_operator(c, :eql?, c3)
assert_equal(false, c.eql?(0)) assert_not_operator(c, :eql?, 0)
end end
def test_hash def test_hash
@ -76,7 +76,7 @@ class Complex_Test < Test::Unit::TestCase
def test_freeze def test_freeze
c = Complex(1) c = Complex(1)
c.freeze c.freeze
assert_equal(true, c.frozen?) assert_predicate(c, :frozen?)
assert_instance_of(String, c.to_s) assert_instance_of(String, c.to_s)
end end
@ -189,14 +189,14 @@ class Complex_Test < Test::Unit::TestCase
def test_attr2 def test_attr2
c = Complex(1) c = Complex(1)
assert_equal(false, c.integer?) assert_not_predicate(c, :integer?)
assert_equal(false, c.real?) assert_not_predicate(c, :real?)
assert_equal(true, Complex(0).zero?) assert_predicate(Complex(0), :zero?)
assert_equal(true, Complex(0,0).zero?) assert_predicate(Complex(0,0), :zero?)
assert_equal(false, Complex(1,0).zero?) assert_not_predicate(Complex(1,0), :zero?)
assert_equal(false, Complex(0,1).zero?) assert_not_predicate(Complex(0,1), :zero?)
assert_equal(false, Complex(1,1).zero?) assert_not_predicate(Complex(1,1), :zero?)
assert_equal(nil, Complex(0).nonzero?) assert_equal(nil, Complex(0).nonzero?)
assert_equal(nil, Complex(0,0).nonzero?) assert_equal(nil, Complex(0,0).nonzero?)
@ -748,35 +748,35 @@ class Complex_Test < Test::Unit::TestCase
def test_respond def test_respond
c = Complex(1,1) c = Complex(1,1)
assert_equal(false, c.respond_to?(:%)) assert_not_respond_to(c, :%)
assert_equal(false, c.respond_to?(:<)) assert_not_respond_to(c, :<)
assert_equal(false, c.respond_to?(:<=)) assert_not_respond_to(c, :<=)
assert_equal(false, c.respond_to?(:<=>)) assert_not_respond_to(c, :<=>)
assert_equal(false, c.respond_to?(:>)) assert_not_respond_to(c, :>)
assert_equal(false, c.respond_to?(:>=)) assert_not_respond_to(c, :>=)
assert_equal(false, c.respond_to?(:between?)) assert_not_respond_to(c, :between?)
assert_equal(false, c.respond_to?(:clamp)) assert_not_respond_to(c, :clamp)
assert_equal(false, c.respond_to?(:div)) assert_not_respond_to(c, :div)
assert_equal(false, c.respond_to?(:divmod)) assert_not_respond_to(c, :divmod)
assert_equal(false, c.respond_to?(:floor)) assert_not_respond_to(c, :floor)
assert_equal(false, c.respond_to?(:ceil)) assert_not_respond_to(c, :ceil)
assert_equal(false, c.respond_to?(:modulo)) assert_not_respond_to(c, :modulo)
assert_equal(false, c.respond_to?(:remainder)) assert_not_respond_to(c, :remainder)
assert_equal(false, c.respond_to?(:round)) assert_not_respond_to(c, :round)
assert_equal(false, c.respond_to?(:step)) assert_not_respond_to(c, :step)
assert_equal(false, c.respond_to?(:tunrcate)) assert_not_respond_to(c, :tunrcate)
assert_equal(false, c.respond_to?(:positive?)) assert_not_respond_to(c, :positive?)
assert_equal(false, c.respond_to?(:negative?)) assert_not_respond_to(c, :negative?)
assert_equal(false, c.respond_to?(:sign)) assert_not_respond_to(c, :sign)
assert_equal(false, c.respond_to?(:quotient)) assert_not_respond_to(c, :quotient)
assert_equal(false, c.respond_to?(:quot)) assert_not_respond_to(c, :quot)
assert_equal(false, c.respond_to?(:quotrem)) assert_not_respond_to(c, :quotrem)
assert_equal(false, c.respond_to?(:gcd)) assert_not_respond_to(c, :gcd)
assert_equal(false, c.respond_to?(:lcm)) assert_not_respond_to(c, :lcm)
assert_equal(false, c.respond_to?(:gcdlcm)) assert_not_respond_to(c, :gcdlcm)
end end
def test_to_i def test_to_i
@ -852,8 +852,8 @@ class Complex_Test < Test::Unit::TestCase
end end
def test_supp def test_supp
assert_equal(true, 1.real?) assert_predicate(1, :real?)
assert_equal(true, 1.1.real?) assert_predicate(1.1, :real?)
assert_equal(1, 1.real) assert_equal(1, 1.real)
assert_equal(0, 1.imag) assert_equal(0, 1.imag)

View File

@ -35,10 +35,10 @@ class Rational_Test < Test::Unit::TestCase
c2 = Rational(0) c2 = Rational(0)
c3 = Rational(1) c3 = Rational(1)
assert_equal(true, c.eql?(c2)) assert_operator(c, :eql?, c2)
assert_equal(false, c.eql?(c3)) assert_not_operator(c, :eql?, c3)
assert_equal(false, c.eql?(0)) assert_not_operator(c, :eql?, 0)
end end
def test_hash def test_hash
@ -60,7 +60,7 @@ class Rational_Test < Test::Unit::TestCase
def test_freeze def test_freeze
c = Rational(1) c = Rational(1)
c.freeze c.freeze
assert_equal(true, c.frozen?) assert_predicate(c, :frozen?)
assert_instance_of(String, c.to_s) assert_instance_of(String, c.to_s)
end end
@ -161,15 +161,15 @@ class Rational_Test < Test::Unit::TestCase
def test_attr2 def test_attr2
c = Rational(1) c = Rational(1)
assert_equal(false, c.integer?) assert_not_predicate(c, :integer?)
assert_equal(true, c.real?) assert_predicate(c, :real?)
assert_equal(true, Rational(0).zero?) assert_predicate(Rational(0), :zero?)
assert_equal(true, Rational(0,1).zero?) assert_predicate(Rational(0,1), :zero?)
assert_equal(false, Rational(1,1).zero?) assert_not_predicate(Rational(1,1), :zero?)
assert_equal(nil, Rational(0).nonzero?) assert_nil(Rational(0).nonzero?)
assert_equal(nil, Rational(0,1).nonzero?) assert_nil(Rational(0,1).nonzero?)
assert_equal(Rational(1,1), Rational(1,1).nonzero?) assert_equal(Rational(1,1), Rational(1,1).nonzero?)
end end
@ -537,23 +537,23 @@ class Rational_Test < Test::Unit::TestCase
assert_equal(-1, Rational(b-1) <=> Rational(b)) assert_equal(-1, Rational(b-1) <=> Rational(b))
assert_equal(+1, Rational(b) <=> Rational(b-1)) assert_equal(+1, Rational(b) <=> Rational(b-1))
assert_equal(false, Rational(0) < Rational(0)) assert_not_operator(Rational(0), :<, Rational(0))
assert_equal(true, Rational(0) <= Rational(0)) assert_operator(Rational(0), :<=, Rational(0))
assert_equal(true, Rational(0) >= Rational(0)) assert_operator(Rational(0), :>=, Rational(0))
assert_equal(false, Rational(0) > Rational(0)) assert_not_operator(Rational(0), :>, Rational(0))
assert_equal(nil, Rational(0) <=> nil) assert_nil(Rational(0) <=> nil)
assert_equal(nil, Rational(0) <=> 'foo') assert_nil(Rational(0) <=> 'foo')
end end
def test_eqeq def test_eqeq
assert_equal(Rational(1,1), Rational(1)) assert_equal(Rational(1,1), Rational(1))
assert_equal(Rational(-1,1), Rational(-1)) assert_equal(Rational(-1,1), Rational(-1))
assert_equal(false, Rational(2,1) == Rational(1)) assert_not_operator(Rational(2,1), :==, Rational(1))
assert_equal(true, Rational(2,1) != Rational(1)) assert_operator(Rational(2,1), :!=, Rational(1))
assert_equal(false, Rational(1) == nil) assert_not_operator(Rational(1), :==, nil)
assert_equal(false, Rational(1) == '') assert_not_operator(Rational(1), :==, '')
end end
def test_coerce def test_coerce
@ -869,8 +869,8 @@ class Rational_Test < Test::Unit::TestCase
end end
def test_supp def test_supp
assert_equal(true, 1.real?) assert_predicate(1, :real?)
assert_equal(true, 1.1.real?) assert_predicate(1.1, :real?)
assert_equal(1, 1.numerator) assert_equal(1, 1.numerator)
assert_equal(9, 9.numerator) assert_equal(9, 9.numerator)