summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--test/ruby/test_complex.rb36
-rw-r--r--test/ruby/test_rational.rb14
3 files changed, 54 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 08fa589f85..d777e4f35c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* complex.c (string_to_c_internal): a refactoring.
diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb
index 02f6eb30ca..9bdcb3a356 100644
--- a/test/ruby/test_complex.rb
+++ b/test/ruby/test_complex.rb
@@ -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(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,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(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), '0.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(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,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(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('0.33'))
assert_equal(Complex(-0.33), Complex('-.33'))
diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb
index 8b992350ab..3d9709517f 100644
--- a/test/ruby/test_rational.rb
+++ b/test/ruby/test_rational.rb
@@ -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(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), '0.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(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('0.33'))
assert_equal(Rational(-33,100), Rational('-.33'))