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 | 64e7ed11fda266dbbd72e6b80acd310149b1ec71 (patch) | |
| tree | f5320945b9bfd9fc19b133335a7be45076fe03e9 /sample | |
| parent | 71898e529579cd40593098e619ed16346a861a50 (diff) | |
| download | ruby-64e7ed11fda266dbbd72e6b80acd310149b1ec71.tar.gz ruby-64e7ed11fda266dbbd72e6b80acd310149b1ec71.tar.xz ruby-64e7ed11fda266dbbd72e6b80acd310149b1ec71.zip | |
matz
git-svn-id: http://svn.ruby-lang.org/repos/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 91355969c..87106330c 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" |
