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

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

View file

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