summaryrefslogtreecommitdiffhomepage
path: root/test/t/integer.rb
diff options
context:
space:
mode:
authorDaniel Bovensiepen <[email protected]>2013-06-15 00:11:12 +0800
committerDaniel Bovensiepen <[email protected]>2013-06-15 00:11:12 +0800
commitb55958b4fa766d845aa247afd8ea93fe10693081 (patch)
treebe465bbaf5c02bf74bc08d60265090139db20d33 /test/t/integer.rb
parent71e12574174523b9b5522392fe1246d02cefa968 (diff)
downloadmruby-b55958b4fa766d845aa247afd8ea93fe10693081.tar.gz
mruby-b55958b4fa766d845aa247afd8ea93fe10693081.zip
Improve Integer Tests
Diffstat (limited to 'test/t/integer.rb')
-rw-r--r--test/t/integer.rb73
1 files changed, 43 insertions, 30 deletions
diff --git a/test/t/integer.rb b/test/t/integer.rb
index 56ea6bf13..46011f94a 100644
--- a/test/t/integer.rb
+++ b/test/t/integer.rb
@@ -2,39 +2,43 @@
# Integer ISO Test
assert('Integer', '15.2.8') do
- Integer.class == Class
+ assert_equal Integer.class, Class
end
assert('Integer superclass', '15.2.8.2') do
- Integer.superclass == Numeric
+ assert_equal Integer.superclass, Numeric
end
assert('Integer#+', '15.2.8.3.1') do
a = 1+1
b = 1+1.0
- a == 2 and b == 2.0
+ assert_equal a, 2
+ assert_equal b, 2.0
end
assert('Integer#-', '15.2.8.3.2') do
a = 2-1
b = 2-1.0
- a == 1 and b == 1.0
+ assert_equal a, 1
+ assert_equal b, 1.0
end
assert('Integer#*', '15.2.8.3.3') do
a = 1*1
b = 1*1.0
- a == 1 and b == 1.0
+ assert_equal a, 1
+ assert_equal b, 1.0
end
assert('Integer#/', '15.2.8.3.4') do
a = 2/1
b = 2/1.0
- a == 2 and b == 2.0
+ assert_equal a, 2
+ assert_equal b, 2.0
end
assert('Integer#%', '15.2.8.3.5') do
@@ -42,7 +46,9 @@ assert('Integer#%', '15.2.8.3.5') do
b = 1%1.0
c = 2%4
- a == 0 and b == 0.0 and c == 2
+ assert_equal a, 0
+ assert_equal b, 0.0
+ assert_equal c, 2
end
assert('Integer#<=>', '15.2.8.3.6') do
@@ -50,19 +56,23 @@ assert('Integer#<=>', '15.2.8.3.6') do
b = 1<=>1
c = 1<=>2
- a == 1 and b == 0 and c == -1
+ assert_equal a, 1
+ assert_equal b, 0
+ assert_equal c, -1
end
assert('Integer#==', '15.2.8.3.7') do
a = 1==0
b = 1==1
- a == false and b == true
+ assert_false a
+ assert_true b
end
assert('Integer#~', '15.2.8.3.8') do
# Complement
- ~0 == -1 and ~2 == -3
+ assert_equal ~0, -1
+ assert_equal ~2, -3
end
assert('Integer#&', '15.2.8.3.9') do
@@ -70,7 +80,7 @@ assert('Integer#&', '15.2.8.3.9') do
# 0101 (5)
# & 0011 (3)
# = 0001 (1)
- 5 & 3 == 1
+ assert_equal 5 & 3, 1
end
assert('Integer#|', '15.2.8.3.10') do
@@ -78,7 +88,7 @@ assert('Integer#|', '15.2.8.3.10') do
# 0101 (5)
# | 0011 (3)
# = 0111 (7)
- 5 | 3 == 7
+ assert_equal 5 | 3, 7
end
assert('Integer#^', '15.2.8.3.11') do
@@ -86,25 +96,25 @@ assert('Integer#^', '15.2.8.3.11') do
# 0101 (5)
# ^ 0011 (3)
# = 0110 (6)
- 5 ^ 3 == 6
+ assert_equal 5 ^ 3, 6
end
assert('Integer#<<', '15.2.8.3.12') do
# Left Shift by one
# 00010111 (23)
# = 00101110 (46)
- 23 << 1 == 46
+ assert_equal 23 << 1, 46
end
assert('Integer#>>', '15.2.8.3.13') do
# Right Shift by one
# 00101110 (46)
# = 00010111 (23)
- 46 >> 1 == 23
+ assert_equal 46 >> 1, 23
end
assert('Integer#ceil', '15.2.8.3.14') do
- 10.ceil == 10
+ assert_equal 10.ceil, 10
end
assert('Integer#downto', '15.2.8.3.15') do
@@ -112,7 +122,7 @@ assert('Integer#downto', '15.2.8.3.15') do
3.downto(1) do |i|
a += i
end
- a == 6
+ assert_equal a, 6
end
assert('Integer#eql?', '15.2.8.3.16') do
@@ -120,25 +130,27 @@ assert('Integer#eql?', '15.2.8.3.16') do
b = 1.eql?(2)
c = 1.eql?(nil)
- a == true and b == false and c == false
+ assert_true a
+ assert_false b
+ assert_false c
end
assert('Integer#floor', '15.2.8.3.17') do
a = 1.floor
- a == 1
+ assert_equal a, 1
end
assert('Integer#next', '15.2.8.3.19') do
- 1.next == 2
+ assert_equal 1.next, 2
end
assert('Integer#round', '15.2.8.3.20') do
- 1.round == 1
+ assert_equal 1.round, 1
end
assert('Integer#succ', '15.2.8.3.21') do
- 1.succ == 2
+ assert_equal 1.succ, 2
end
assert('Integer#times', '15.2.8.3.22') do
@@ -146,23 +158,24 @@ assert('Integer#times', '15.2.8.3.22') do
3.times do
a += 1
end
- a == 3
+ assert_equal a, 3
end
assert('Integer#to_f', '15.2.8.3.23') do
- 1.to_f == 1.0
+ assert_equal 1.to_f, 1.0
end
assert('Integer#to_i', '15.2.8.3.24') do
- 1.to_i == 1
+ assert_equal 1.to_i, 1
end
assert('Integer#to_s', '15.2.8.3.25') do
- 1.to_s == '1' and -1.to_s == "-1"
+ assert_equal 1.to_s, '1'
+ assert_equal(-1.to_s, "-1")
end
assert('Integer#truncate', '15.2.8.3.26') do
- 1.truncate == 1
+ assert_equal 1.truncate, 1
end
assert('Integer#upto', '15.2.8.3.27') do
@@ -170,7 +183,7 @@ assert('Integer#upto', '15.2.8.3.27') do
1.upto(3) do |i|
a += i
end
- a == 6
+ assert_equal a, 6
end
# Not ISO specified
@@ -185,6 +198,6 @@ assert('Integer#step') do
b << i
end
- a == [1, 2, 3] and
- b == [1, 3, 5]
+ assert_equal a, [1, 2, 3]
+ assert_equal b, [1, 3, 5]
end