summaryrefslogtreecommitdiffhomepage
path: root/test/t/float.rb
diff options
context:
space:
mode:
authorDaniel Bovensiepen <[email protected]>2013-06-14 21:50:22 +0800
committerDaniel Bovensiepen <[email protected]>2013-06-14 21:50:22 +0800
commit04191cc82974446992630fa23625e30b832a6f6d (patch)
tree0ee9a1501a0dc01792062ac9016c268c183e18c6 /test/t/float.rb
parent60d230d0fdf9a6e22ae13f30cb11f4c948c1d62b (diff)
downloadmruby-04191cc82974446992630fa23625e30b832a6f6d.tar.gz
mruby-04191cc82974446992630fa23625e30b832a6f6d.zip
Improve Float Tests
Diffstat (limited to 'test/t/float.rb')
-rw-r--r--test/t/float.rb72
1 files changed, 47 insertions, 25 deletions
diff --git a/test/t/float.rb b/test/t/float.rb
index abb5cf2e7..7f4824472 100644
--- a/test/t/float.rb
+++ b/test/t/float.rb
@@ -2,51 +2,51 @@
# Float ISO Test
assert('Float', '15.2.9') do
- Float.class == Class
+ assert_equal Float.class, Class
end
assert('Float superclass', '15.2.9.2') do
- Float.superclass == Numeric
+ assert_equal Float.superclass, Numeric
end
assert('Float#+', '15.2.9.3.1') do
a = 3.123456788 + 0.000000001
b = 3.123456789 + 1
- check_float(a, 3.123456789) and
- check_float(b, 4.123456789)
+ assert_float(a, 3.123456789)
+ assert_float(b, 4.123456789)
end
assert('Float#-', '15.2.9.3.2') do
a = 3.123456790 - 0.000000001
b = 5.123456789 - 1
- check_float(a, 3.123456789) and
- check_float(b, 4.123456789)
+ assert_float(a, 3.123456789)
+ assert_float(b, 4.123456789)
end
assert('Float#*', '15.2.9.3.3') do
a = 3.125 * 3.125
b = 3.125 * 1
- check_float(a, 9.765625) and
- check_float(b, 3.125)
+ assert_float(a, 9.765625)
+ assert_float(b, 3.125)
end
assert('Float#/', '15.2.9.3.4') do
a = 3.123456789 / 3.123456789
b = 3.123456789 / 1
- check_float(a, 1.0) and
- check_float(b, 3.123456789)
+ assert_float(a, 1.0)
+ assert_float(b, 3.123456789)
end
assert('Float#%', '15.2.9.3.5') do
a = 3.125 % 3.125
b = 3.125 % 1
- check_float(a, 0.0) and
- check_float(b, 0.125)
+ assert_float(a, 0.0)
+ assert_float(b, 0.125)
end
assert('Float#<=>', '15.2.9.3.6') do
@@ -56,12 +56,16 @@ assert('Float#<=>', '15.2.9.3.6') do
a2 = 3.125 <=> 3
c2 = 3.125 <=> 4
- a == 1 and b == 0 and c == -1 and
- a2 == 1 and c2 == -1
+ assert_equal a, 1
+ assert_equal b, 0
+ assert_equal c, -1
+ assert_equal a2, 1
+ assert_equal c2, -1
end
assert('Float#==', '15.2.9.3.7') do
- 3.1 == 3.1 and not 3.1 == 3.2
+ assert_true 3.1 == 3.1
+ assert_false 3.1 == 3.2
end
assert('Float#ceil', '15.2.9.3.8') do
@@ -69,12 +73,16 @@ assert('Float#ceil', '15.2.9.3.8') do
b = 3.0.ceil
c = -3.123456789.ceil
d = -3.0.ceil
- a == 4 and b == 3 and c == -3 and d == -3
+
+ assert_equal a, 4
+ assert_equal b, 3
+ assert_equal c, -3
+ assert_equal d, -3
end
assert('Float#finite?', '15.2.9.3.9') do
- 3.123456789.finite? and
- not (1.0 / 0.0).finite?
+ assert_true 3.123456789.finite?
+ assert_false (1.0 / 0.0).finite?
end
assert('Float#floor', '15.2.9.3.10') do
@@ -82,7 +90,11 @@ assert('Float#floor', '15.2.9.3.10') do
b = 3.0.floor
c = -3.123456789.floor
d = -3.0.floor
- a == 3 and b == 3 and c == -4 and d == -3
+
+ assert_equal a, 3
+ assert_equal b, 3
+ assert_equal c, -4
+ assert_equal d, -3
end
assert('Float#infinite?', '15.2.9.3.11') do
@@ -90,7 +102,9 @@ assert('Float#infinite?', '15.2.9.3.11') do
b = (1.0 / 0.0).infinite?
c = (-1.0 / 0.0).infinite?
- a == nil and b == 1 and c == -1
+ assert_nil a
+ assert_equal b, 1
+ assert_equal c, -1
end
assert('Float#round', '15.2.9.3.12') do
@@ -104,20 +118,28 @@ assert('Float#round', '15.2.9.3.12') do
h = 3.423456789.round(1)
i = 3.423456789.round(3)
- a == 3 and b == 4 and c == 3 and d == -3 and e == -4 and
- f == 12350 and g == 3 and check_float(h, 3.4) and check_float(i, 3.423)
+ assert_equal a, 3
+ assert_equal b, 4
+ assert_equal c, 3
+ assert_equal d, -3
+ assert_equal e, -4
+ assert_equal f, 12350
+ assert_equal g, 3
+ assert_float(h, 3.4)
+ assert_float(i, 3.423)
end
assert('Float#to_f', '15.2.9.3.13') do
a = 3.123456789
- check_float(a.to_f, a)
+ assert_float(a.to_f, a)
end
assert('Float#to_i', '15.2.9.3.14') do
- 3.123456789.to_i == 3
+ assert_equal 3.123456789.to_i, 3
end
assert('Float#truncate', '15.2.9.3.15') do
- 3.123456789.truncate == 3 and -3.1.truncate == -3
+ assert_equal 3.123456789.truncate, 3
+ assert_equal -3.1.truncate, -3
end