diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-07-06 07:21:26 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-07-06 07:21:26 +0000 |
commit | d1375688cdde3d094984f7f3a7bffe57306a0bca (patch) | |
tree | f5320945b9bfd9fc19b133335a7be45076fe03e9 /sample | |
parent | a60db057a2a8456f8f5b59a6c5805e25d1d47d34 (diff) | |
download | ruby-d1375688cdde3d094984f7f3a7bffe57306a0bca.tar.gz |
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample')
-rw-r--r-- | sample/test.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/sample/test.rb b/sample/test.rb index 91355969c9..87106330cc 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" |