summaryrefslogtreecommitdiffstats
path: root/sample
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-11 06:56:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-11 06:56:13 +0000
commit6a8b8c0cab232a9a6cc79c34bfe64bd5b0031f46 (patch)
treeed24d2b39a2ad21759673eea3b8ba1b29d5ad700 /sample
parent044746e1eaab2fb0a355cd080ffc480ad09ed8aa (diff)
downloadruby-6a8b8c0cab232a9a6cc79c34bfe64bd5b0031f46.tar.gz
ruby-6a8b8c0cab232a9a6cc79c34bfe64bd5b0031f46.tar.xz
ruby-6a8b8c0cab232a9a6cc79c34bfe64bd5b0031f46.zip
* sample/test.rb: NaN comparison test.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r--sample/test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/sample/test.rb b/sample/test.rb
index 3f9253b3a..b41ac7c9c 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -972,6 +972,28 @@ test_ok((-2.6).truncate == -2)
test_ok(2.6.round == 3)
test_ok((-2.4).truncate == -2)
test_ok((13.4 % 1 - 0.4).abs < 0.0001)
+nan = 0.0/0
+def nan.test(v)
+ test_ok(self != v)
+ test_ok((self < v) == false)
+ test_ok((self > v) == false)
+ test_ok((self <= v) == false)
+ test_ok((self >= v) == false)
+end
+nan.test(nan)
+nan.test(0)
+nan.test(1)
+nan.test(-1)
+nan.test(1000)
+nan.test(-1000)
+nan.test(1_000_000_000_000)
+nan.test(-1_000_000_000_000)
+nan.test(100.0);
+nan.test(-100.0);
+nan.test(0.001);
+nan.test(-0.001);
+nan.test(1.0/0);
+nan.test(-1.0/0);
test_check "bignum"
def fact(n)