From fd0fdbe90880a202b8570760a81e6952e6980170 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 11 Apr 2003 06:56:13 +0000 Subject: * sample/test.rb: NaN comparison test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sample/test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'sample') diff --git a/sample/test.rb b/sample/test.rb index 3f9253b3ac..b41ac7c9c4 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) -- cgit v1.2.3