summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_prec.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-07 15:09:12 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-07 15:09:12 +0000
commit99a739c55f90ddf3526bc75bd4337f44d4f1b6f5 (patch)
tree051efbdc49a2d8db94b4a12e11ccd10f37fb78ee /test/ruby/test_prec.rb
parentc22cb0aa11a4ae6edd113b455b6a444f73db0885 (diff)
downloadruby-99a739c55f90ddf3526bc75bd4337f44d4f1b6f5.tar.gz
ruby-99a739c55f90ddf3526bc75bd4337f44d4f1b6f5.tar.xz
ruby-99a739c55f90ddf3526bc75bd4337f44d4f1b6f5.zip
* test/ruby/test_hash.rb: follow the change of Hash#flatten.
* test/ruby/test_time.rb: add tests to achieve over 70% test coverage of time.c. * test/ruby/test_prec.rb: ditto over 90% for prec.c. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_prec.rb')
-rw-r--r--test/ruby/test_prec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_prec.rb b/test/ruby/test_prec.rb
new file mode 100644
index 000000000..d872242c1
--- /dev/null
+++ b/test/ruby/test_prec.rb
@@ -0,0 +1,21 @@
+require 'test/unit'
+
+class TestPrecision < Test::Unit::TestCase
+ def test_prec_i
+ assert_same(1, 1.0.prec(Integer))
+ assert_same(1, 1.0.prec_i)
+ assert_same(1, Integer.induced_from(1.0))
+ end
+
+ def test_prec_f
+ assert_equal(1.0, 1.prec(Float))
+ assert_equal(1.0, 1.prec_f)
+ assert_equal(1.0, Float.induced_from(1))
+ end
+
+ def test_induced_from
+ m = Module.new
+ m.instance_eval { include(Precision) }
+ assert_raise(TypeError) { m.induced_from(0) }
+ end
+end