mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_{complex,rational}.rb: added tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6c81a8e44e
commit
c1f80caa54
3 changed files with 54 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Mon May 9 20:57:13 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
|
* test/ruby/test_{complex,rational}.rb: added tests.
|
||||||
|
|
||||||
Mon May 9 20:29:44 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
Mon May 9 20:29:44 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* complex.c (string_to_c_internal): a refactoring.
|
* complex.c (string_to_c_internal): a refactoring.
|
||||||
|
|
|
@ -689,6 +689,15 @@ class Complex_Test < Test::Unit::TestCase
|
||||||
assert_equal(Complex(0.0,3.0), '3.0i'.to_c)
|
assert_equal(Complex(0.0,3.0), '3.0i'.to_c)
|
||||||
assert_equal(Complex(0.0,-3.0), '-3.0i'.to_c)
|
assert_equal(Complex(0.0,-3.0), '-3.0i'.to_c)
|
||||||
|
|
||||||
|
assert_equal(Complex(5.1), '5.1'.to_c)
|
||||||
|
assert_equal(Complex(-5.2), '-5.2'.to_c)
|
||||||
|
assert_equal(Complex(5.3,3.4), '5.3+3.4i'.to_c)
|
||||||
|
assert_equal(Complex(-5.5,3.6), '-5.5+3.6i'.to_c)
|
||||||
|
assert_equal(Complex(5.3,-3.4), '5.3-3.4i'.to_c)
|
||||||
|
assert_equal(Complex(-5.5,-3.6), '-5.5-3.6i'.to_c)
|
||||||
|
assert_equal(Complex(0.0,3.1), '3.1i'.to_c)
|
||||||
|
assert_equal(Complex(0.0,-3.2), '-3.2i'.to_c)
|
||||||
|
|
||||||
assert_equal(Complex(5.0), '5e0'.to_c)
|
assert_equal(Complex(5.0), '5e0'.to_c)
|
||||||
assert_equal(Complex(-5.0), '-5e0'.to_c)
|
assert_equal(Complex(-5.0), '-5e0'.to_c)
|
||||||
assert_equal(Complex(5.0,3.0), '5e0+3e0i'.to_c)
|
assert_equal(Complex(5.0,3.0), '5e0+3e0i'.to_c)
|
||||||
|
@ -698,6 +707,15 @@ class Complex_Test < Test::Unit::TestCase
|
||||||
assert_equal(Complex(0.0,3.0), '3e0i'.to_c)
|
assert_equal(Complex(0.0,3.0), '3e0i'.to_c)
|
||||||
assert_equal(Complex(0.0,-3.0), '-3e0i'.to_c)
|
assert_equal(Complex(0.0,-3.0), '-3e0i'.to_c)
|
||||||
|
|
||||||
|
assert_equal(Complex(5e1), '5e1'.to_c)
|
||||||
|
assert_equal(Complex(-5e2), '-5e2'.to_c)
|
||||||
|
assert_equal(Complex(5e3,3e4), '5e003+3e4i'.to_c)
|
||||||
|
assert_equal(Complex(-5e5,3e6), '-5e5+3e006i'.to_c)
|
||||||
|
assert_equal(Complex(5e3,-3e4), '5e003-3e4i'.to_c)
|
||||||
|
assert_equal(Complex(-5e5,-3e6), '-5e5-3e006i'.to_c)
|
||||||
|
assert_equal(Complex(0.0,3e1), '3e1i'.to_c)
|
||||||
|
assert_equal(Complex(0.0,-3e2), '-3e2i'.to_c)
|
||||||
|
|
||||||
assert_equal(Complex(0.33), '.33'.to_c)
|
assert_equal(Complex(0.33), '.33'.to_c)
|
||||||
assert_equal(Complex(0.33), '0.33'.to_c)
|
assert_equal(Complex(0.33), '0.33'.to_c)
|
||||||
assert_equal(Complex(-0.33), '-.33'.to_c)
|
assert_equal(Complex(-0.33), '-.33'.to_c)
|
||||||
|
@ -740,6 +758,15 @@ class Complex_Test < Test::Unit::TestCase
|
||||||
assert_equal(Complex(0.0,3.0), Complex('3.0i'))
|
assert_equal(Complex(0.0,3.0), Complex('3.0i'))
|
||||||
assert_equal(Complex(0.0,-3.0), Complex('-3.0i'))
|
assert_equal(Complex(0.0,-3.0), Complex('-3.0i'))
|
||||||
|
|
||||||
|
assert_equal(Complex(5.1), Complex('5.1'))
|
||||||
|
assert_equal(Complex(-5.2), Complex('-5.2'))
|
||||||
|
assert_equal(Complex(5.3,3.4), Complex('5.3+3.4i'))
|
||||||
|
assert_equal(Complex(-5.5,3.6), Complex('-5.5+3.6i'))
|
||||||
|
assert_equal(Complex(5.3,-3.4), Complex('5.3-3.4i'))
|
||||||
|
assert_equal(Complex(-5.5,-3.6), Complex('-5.5-3.6i'))
|
||||||
|
assert_equal(Complex(0.0,3.1), Complex('3.1i'))
|
||||||
|
assert_equal(Complex(0.0,-3.2), Complex('-3.2i'))
|
||||||
|
|
||||||
assert_equal(Complex(5.0), Complex('5e0'))
|
assert_equal(Complex(5.0), Complex('5e0'))
|
||||||
assert_equal(Complex(-5.0), Complex('-5e0'))
|
assert_equal(Complex(-5.0), Complex('-5e0'))
|
||||||
assert_equal(Complex(5.0,3.0), Complex('5e0+3e0i'))
|
assert_equal(Complex(5.0,3.0), Complex('5e0+3e0i'))
|
||||||
|
@ -749,6 +776,15 @@ class Complex_Test < Test::Unit::TestCase
|
||||||
assert_equal(Complex(0.0,3.0), Complex('3e0i'))
|
assert_equal(Complex(0.0,3.0), Complex('3e0i'))
|
||||||
assert_equal(Complex(0.0,-3.0), Complex('-3e0i'))
|
assert_equal(Complex(0.0,-3.0), Complex('-3e0i'))
|
||||||
|
|
||||||
|
assert_equal(Complex(5e1), Complex('5e1'))
|
||||||
|
assert_equal(Complex(-5e2), Complex('-5e2'))
|
||||||
|
assert_equal(Complex(5e3,3e4), Complex('5e003+3e4i'))
|
||||||
|
assert_equal(Complex(-5e5,3e6), Complex('-5e5+3e006i'))
|
||||||
|
assert_equal(Complex(5e3,-3e4), Complex('5e003-3e4i'))
|
||||||
|
assert_equal(Complex(-5e5,-3e6), Complex('-5e5-3e006i'))
|
||||||
|
assert_equal(Complex(0.0,3e1), Complex('3e1i'))
|
||||||
|
assert_equal(Complex(0.0,-3e2), Complex('-3e2i'))
|
||||||
|
|
||||||
assert_equal(Complex(0.33), Complex('.33'))
|
assert_equal(Complex(0.33), Complex('.33'))
|
||||||
assert_equal(Complex(0.33), Complex('0.33'))
|
assert_equal(Complex(0.33), Complex('0.33'))
|
||||||
assert_equal(Complex(-0.33), Complex('-.33'))
|
assert_equal(Complex(-0.33), Complex('-.33'))
|
||||||
|
|
|
@ -851,6 +851,13 @@ class Rational_Test < Test::Unit::TestCase
|
||||||
# assert_equal(Rational(5,-3), '5e0/-3'.to_r)
|
# assert_equal(Rational(5,-3), '5e0/-3'.to_r)
|
||||||
# assert_equal(Rational(-5,-3), '-5e0/-3'.to_r)
|
# assert_equal(Rational(-5,-3), '-5e0/-3'.to_r)
|
||||||
|
|
||||||
|
assert_equal(Rational(5e1), '5e1'.to_r)
|
||||||
|
assert_equal(Rational(-5e2), '-5e2'.to_r)
|
||||||
|
assert_equal(Rational(5e3,3), '5e003/3'.to_r)
|
||||||
|
assert_equal(Rational(-5e4,3), '-5e004/3'.to_r)
|
||||||
|
# assert_equal(Rational(5e1,-3), '5e1/-3'.to_r)
|
||||||
|
# assert_equal(Rational(-5e2,-3), '-5e2/-3'.to_r)
|
||||||
|
|
||||||
assert_equal(Rational(33,100), '.33'.to_r)
|
assert_equal(Rational(33,100), '.33'.to_r)
|
||||||
assert_equal(Rational(33,100), '0.33'.to_r)
|
assert_equal(Rational(33,100), '0.33'.to_r)
|
||||||
assert_equal(Rational(-33,100), '-.33'.to_r)
|
assert_equal(Rational(-33,100), '-.33'.to_r)
|
||||||
|
@ -888,6 +895,13 @@ class Rational_Test < Test::Unit::TestCase
|
||||||
# assert_equal(Rational(5,-3), Rational('5e0/-3'))
|
# assert_equal(Rational(5,-3), Rational('5e0/-3'))
|
||||||
# assert_equal(Rational(-5,-3), Rational('-5e0/-3'))
|
# assert_equal(Rational(-5,-3), Rational('-5e0/-3'))
|
||||||
|
|
||||||
|
assert_equal(Rational(5e1), Rational('5e1'))
|
||||||
|
assert_equal(Rational(-5e2), Rational('-5e2'))
|
||||||
|
assert_equal(Rational(5e3,3), Rational('5e003/3'))
|
||||||
|
assert_equal(Rational(-5e4,3), Rational('-5e004/3'))
|
||||||
|
# assert_equal(Rational(5e1,-3), Rational('5e1/-3'))
|
||||||
|
# assert_equal(Rational(-5e2,-3), Rational('-5e2/-3'))
|
||||||
|
|
||||||
assert_equal(Rational(33,100), Rational('.33'))
|
assert_equal(Rational(33,100), Rational('.33'))
|
||||||
assert_equal(Rational(33,100), Rational('0.33'))
|
assert_equal(Rational(33,100), Rational('0.33'))
|
||||||
assert_equal(Rational(-33,100), Rational('-.33'))
|
assert_equal(Rational(-33,100), Rational('-.33'))
|
||||||
|
|
Loading…
Reference in a new issue