summaryrefslogtreecommitdiff
path: root/sample/test.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-06 07:21:26 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-07-06 07:21:26 +0000
commitd1375688cdde3d094984f7f3a7bffe57306a0bca (patch)
treef5320945b9bfd9fc19b133335a7be45076fe03e9 /sample/test.rb
parenta60db057a2a8456f8f5b59a6c5805e25d1d47d34 (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/test.rb')
-rw-r--r--sample/test.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/sample/test.rb b/sample/test.rb
index 9135596..8710633 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -550,6 +550,17 @@ ok($x == [0,0])
IterTest.new([[8,8]]).each8 { |x| $x = x }
ok($x == [8,8])
+check "float"
+ok(2.6.floor == 2)
+ok(-2.6.floor == -3)
+ok(2.6.ceil == 3)
+ok(-2.6.ceil == -2)
+ok(2.6.truncate == 2)
+ok(-2.6.truncate == -2)
+ok(2.6.round == 3)
+ok(-2.4.truncate == -2)
+ok((13.4 % 1 - 0.4).abs < 0.0001)
+
check "bignum"
def fact(n)
return 1 if n == 0
@@ -609,10 +620,14 @@ ok($good)
b = 10**80
a = b * 9 + 7
-ok(7 ==a % b)
-ok(7 ==a % -b)
-ok(-7 == (-a) % b)
-ok(-7 == (-a) % (-b))
+ok(7 == a.modulo(b))
+ok(-b + 7 == a.modulo(-b))
+ok(b + -7 == (-a).modulo(b))
+ok(-7 == (-a).modulo(-b))
+ok(7 == a.remainder(b))
+ok(7 == a.remainder(-b))
+ok(-7 == (-a).remainder(b))
+ok(-7 == (-a).remainder(-b))
check "string & char"