summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-06-16 20:44:22 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-06-16 20:44:22 +0900
commitef5087bc9ad921e35b93b9d274c35518c0d94170 (patch)
treef254dd3629ad56a19bf21ef9c4276dea62195c8c /test
parent7ba2f8554629b8b0cf088ff7c7a2f33d31873e93 (diff)
parent6025f2c4ba682e72882189ba03ed7b4ca46c6237 (diff)
downloadmruby-ef5087bc9ad921e35b93b9d274c35518c0d94170.tar.gz
mruby-ef5087bc9ad921e35b93b9d274c35518c0d94170.zip
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'test')
-rw-r--r--test/assert.rb24
-rw-r--r--test/t/bs_block.rb265
-rw-r--r--test/t/bs_literal.rb18
-rw-r--r--test/t/float.rb72
-rw-r--r--test/t/gc.rb20
-rw-r--r--test/t/indexerror.rb5
-rw-r--r--test/t/literals.rb2
-rw-r--r--test/t/localjumperror.rb7
-rw-r--r--test/t/nameerror.rb12
-rw-r--r--test/t/nil.rb16
-rw-r--r--test/t/nomethoderror.rb11
-rw-r--r--test/t/numeric.rb13
-rw-r--r--test/t/object.rb4
-rw-r--r--test/t/proc.rb25
-rw-r--r--test/t/rangeerror.rb5
-rw-r--r--test/t/runtimeerror.rb2
-rw-r--r--test/t/standarderror.rb5
-rw-r--r--test/t/symbol.rb13
-rw-r--r--test/t/true.rb17
-rw-r--r--test/t/typeerror.rb4
20 files changed, 315 insertions, 225 deletions
diff --git a/test/assert.rb b/test/assert.rb
index 6d727e889..dc282925f 100644
--- a/test/assert.rb
+++ b/test/assert.rb
@@ -99,13 +99,25 @@ def assert_false(ret, msg = nil, diff = nil)
!ret
end
-def assert_equal(exp, act, msg = nil)
+def assert_equal(arg1, arg2 = nil, arg3 = nil)
+ if block_given?
+ exp, act, msg = yield, arg1, arg2
+ else
+ exp, act, msg = arg1, arg2, arg3
+ end
+
msg = "Expected to be equal" unless msg
diff = assertion_diff(exp, act)
assert_true(exp == act, msg, diff)
end
-def assert_not_equal(exp, act, msg = nil)
+def assert_not_equal(arg1, arg2 = nil, arg3 = nil)
+ if block_given?
+ exp, act, msg = yield, arg1, arg2
+ else
+ exp, act, msg = arg1, arg2, arg3
+ end
+
msg = "Expected to be not equal" unless msg
diff = assertion_diff(exp, act)
assert_false(exp == act, msg, diff)
@@ -170,6 +182,14 @@ def assert_kind_of(cls, obj, msg = nil)
end
##
+# Fails unless +exp+ is equal to +act+ in terms of a Float
+def assert_float(exp, act, msg = nil)
+ msg = "Float #{exp} expected to be equal to float #{act}" unless msg
+ diff = assertion_diff(exp, act)
+ assert_true check_float(exp, act), msg, diff
+end
+
+##
# Report the test result and print all assertions
# which were reported broken.
def report()
diff --git a/test/t/bs_block.rb b/test/t/bs_block.rb
index 10313908b..47ecece86 100644
--- a/test/t/bs_block.rb
+++ b/test/t/bs_block.rb
@@ -2,17 +2,19 @@
# Bootstrap tests for blocks
assert('BS Block 1') do
- 1.times{
- begin
- a = 1
- ensure
- foo = nil
- end
- } == 1
+ assert_equal(1) do
+ 1.times{
+ begin
+ a = 1
+ ensure
+ foo = nil
+ end
+ }
+ end
end
assert('BS Block 2') do
- [1,2,3].find{|x| x == 2} == 2
+ assert_equal [1,2,3].find{|x| x == 2}, 2
end
assert('BS Block 3') do
@@ -22,7 +24,7 @@ assert('BS Block 3') do
[1, 2, 3].each(&block)
end
end
- E.new.find {|x| x == 2 } == 2
+ assert_equal E.new.find {|x| x == 2 }, 2
end
assert('BS Block 3') do
@@ -30,7 +32,7 @@ assert('BS Block 3') do
for x in [1, 2, 3]
sum += x
end
- sum == 6
+ assert_equal sum, 6
end
assert('BS Block 4') do
@@ -38,7 +40,7 @@ assert('BS Block 4') do
for x in (1..5)
sum += x
end
- sum == 15
+ assert_equal sum, 15
end
assert('BS Block 5') do
@@ -46,37 +48,43 @@ assert('BS Block 5') do
for x in []
sum += x
end
- sum == 0
+ assert_equal sum, 0
end
assert('BS Block 6') do
ans = []
- 1.times{
- for n in 1..3
- a = n
- ans << a
- end
- } == 1
+ assert_equal(1) do
+ 1.times{
+ for n in 1..3
+ a = n
+ ans << a
+ end
+ }
+ end
end
assert('BS Block 7') do
ans = []
- for m in 1..3
- for n in 2..4
- a = [m, n]
- ans << a
+ assert_equal((1..3)) do
+ for m in 1..3
+ for n in 2..4
+ a = [m, n]
+ ans << a
+ end
end
- end == (1..3)
+ end
end
assert('BS Block 8') do
- (1..3).to_a == [1, 2, 3]
+ assert_equal (1..3).to_a, [1, 2, 3]
end
assert('BS Block 9') do
- (1..3).map{|e|
- e * 4
- } == [4, 8, 12]
+ assert_equal([4, 8, 12]) do
+ (1..3).map{|e|
+ e * 4
+ }
+ end
end
assert('BS Block 10') do
@@ -87,11 +95,13 @@ assert('BS Block 10') do
yield
end
- m{
- n{
- 100
+ assert_equal(100) do
+ m{
+ n{
+ 100
+ }
}
- } == 100
+ end
end
assert('BS Block 11') do
@@ -99,11 +109,13 @@ assert('BS Block 11') do
yield 1
end
- m{|ib|
- m{|jb|
- i = 20
+ assert_equal(20) do
+ m{|ib|
+ m{|jb|
+ i = 20
+ }
}
- } == 20
+ end
end
assert('BS Block 12') do
@@ -111,12 +123,14 @@ assert('BS Block 12') do
yield 1
end
- m{|ib|
- m{|jb|
- ib = 20
- kb = 2
+ assert_equal(2) do
+ m{|ib|
+ m{|jb|
+ ib = 20
+ kb = 2
+ }
}
- } == 2
+ end
end
assert('BS Block 13') do
@@ -130,13 +144,15 @@ assert('BS Block 13') do
yield
end
- iter1{
- jb = 2
+ assert_equal(3) do
iter1{
- jb = 3
+ jb = 2
+ iter1{
+ jb = 3
+ }
+ jb
}
- jb
- } == 3
+ end
end
assert('BS Block 14') do
@@ -150,31 +166,37 @@ assert('BS Block 14') do
yield
end
- iter1{
- jb = 2
+ assert_equal(2) do
iter1{
+ jb = 2
+ iter1{
+ jb
+ }
jb
}
- jb
- } == 2
+ end
end
assert('BS Block 15') do
def m
yield 1
end
- m{|ib|
- ib*2
- } == 2
+ assert_equal(2) do
+ m{|ib|
+ ib*2
+ }
+ end
end
assert('BS Block 16') do
def m
yield 12345, 67890
end
- m{|ib,jb|
- ib*2+jb
- } == 92580
+ assert_equal(92580) do
+ m{|ib,jb|
+ ib*2+jb
+ }
+ end
end
assert('BS Block 17') do
@@ -183,9 +205,11 @@ assert('BS Block 17') do
end
a = nil
- [iter{|a|
- a
- }, a] == [10, nil]
+ assert_equal [10, nil] do
+ [iter{|a|
+ a
+ }, a]
+ end
end
assert('BS Block 18') do
@@ -193,11 +217,13 @@ assert('BS Block 18') do
yield 10
end
- iter{|a|
+ assert_equal(21) do
iter{|a|
- a + 1
- } + a
- } == 21
+ iter{|a|
+ a + 1
+ } + a
+ }
+ end
end
assert('BS Block 19') do
@@ -206,9 +232,11 @@ assert('BS Block 19') do
end
a = b = c = d = nil
- iter{|a, b, c, d|
- [a, b, c, d]
- } + [a, b, c, d] == [10, 20, 30, 40, nil, nil, nil, nil]
+ assert_equal([10, 20, 30, 40, nil, nil, nil, nil]) do
+ iter{|a, b, c, d|
+ [a, b, c, d]
+ } + [a, b, c, d]
+ end
end
assert('BS Block 20') do
@@ -217,9 +245,11 @@ assert('BS Block 20') do
end
a = b = nil
- iter{|a, b, c, d|
- [a, b, c, d]
- } + [a, b] == [10, 20, 30, 40, nil, nil]
+ assert_equal([10, 20, 30, 40, nil, nil]) do
+ iter{|a, b, c, d|
+ [a, b, c, d]
+ } + [a, b]
+ end
end
assert('BS Block 21') do
@@ -227,9 +257,11 @@ assert('BS Block 21') do
yield 1, 2
end
- iter{|a, *b|
- [a, b]
- } == [1, [2]]
+ assert_equal([1, [2]]) do
+ iter{|a, *b|
+ [a, b]
+ }
+ end
end
assert('BS Block 22') do
@@ -237,9 +269,11 @@ assert('BS Block 22') do
yield 1, 2
end
- iter{|*a|
- [a]
- } == [[1, 2]]
+ assert_equal([[1, 2]]) do
+ iter{|*a|
+ [a]
+ }
+ end
end
assert('BS Block 23') do
@@ -247,40 +281,48 @@ assert('BS Block 23') do
yield 1, 2
end
- iter{|a, b, *c|
- [a, b, c]
- } == [1, 2, []]
+ assert_equal([1, 2, []]) do
+ iter{|a, b, *c|
+ [a, b, c]
+ }
+ end
end
assert('BS Block 24') do
def m
yield
end
- m{
- 1
- } == 1
+ assert_equal(1) do
+ m{
+ 1
+ }
+ end
end
assert('BS Block 25') do
def m
yield 123
end
- m{|ib|
- m{|jb|
- ib*jb
+ assert_equal(15129) do
+ m{|ib|
+ m{|jb|
+ ib*jb
+ }
}
- } == 15129
+ end
end
assert('BS Block 26') do
def m a
yield a
end
- m(1){|ib|
- m(2){|jb|
- ib*jb
+ assert_equal(2) do
+ m(1){|ib|
+ m(2){|jb|
+ ib*jb
+ }
}
- } == 2
+ end
end
assert('BS Block 27') do
@@ -289,13 +331,15 @@ assert('BS Block 27') do
2.times{|jb|
sum += ib + jb
}}
- sum == 9
+ assert_equal sum, 9
end
assert('BS Block 28') do
- 3.times{|bl|
- break 10
- } == 10
+ assert_equal(10) do
+ 3.times{|bl|
+ break 10
+ }
+ end
end
assert('BS Block 29') do
@@ -303,9 +347,11 @@ assert('BS Block 29') do
yield 1,2,3
end
- iter{|i, j|
- [i, j]
- } == [1, 2]
+ assert_equal([1, 2]) do
+ iter{|i, j|
+ [i, j]
+ }
+ end
end
assert('BS Block 30') do
@@ -313,23 +359,25 @@ assert('BS Block 30') do
yield 1
end
- iter{|i, j|
- [i, j]
- } == [1, nil]
+ assert_equal([1, nil]) do
+ iter{|i, j|
+ [i, j]
+ }
+ end
end
assert('BS Block [ruby-dev:31147]') do
def m
yield
end
- m{|&b| b} == nil
+ assert_nil m{|&b| b}
end
assert('BS Block [ruby-dev:31160]') do
def m()
yield
end
- m {|(v,(*))|} == nil
+ assert_nil m {|(v,(*))|}
end
assert('BS Block [issue #750]') do
@@ -337,25 +385,26 @@ assert('BS Block [issue #750]') do
yield
end
args = [1, 2, 3]
- m(*args){ 1 } == 1
+ assert_equal m(*args){ 1 }, 1
end
assert('BS Block 31') do
def m()
yield
end
- m {|((*))|} == nil
+ assert_nil m {|((*))|}
end
assert('BS Block [ruby-dev:31440]') do
def m
yield [0]
end
- m{|v, &b| v} == [0]
+ assert_equal m{|v, &b| v}, [0]
end
assert('BS Block 32') do
- r = false; 1.times{|&b| r = b}; r.class == NilClass
+ r = false; 1.times{|&b| r = b}
+ assert_equal r.class, NilClass
end
assert('BS Block [ruby-core:14395]') do
@@ -394,7 +443,7 @@ assert('BS Block [ruby-core:14395]') do
end
end
t = Controller.new
- t.test_for_bug
+ assert_true t.test_for_bug
end
assert("BS Block 33") do
@@ -408,7 +457,7 @@ assert("BS Block 33") do
:bad
end
end
- TestReturnFromNestedBlock.test == :ok
+ assert_equal TestReturnFromNestedBlock.test, :ok
end
assert("BS Block 34") do
@@ -422,7 +471,7 @@ assert("BS Block 34") do
:bad
end
end
- TestReturnFromNestedBlock_BSBlock34.test == :ok
+ assert_equal TestReturnFromNestedBlock_BSBlock34.test, :ok
end
assert("BS Block 35") do
@@ -436,5 +485,5 @@ assert("BS Block 35") do
:bad
end
end
- TestReturnFromNestedBlock_BSBlock35.test == :ok
+ assert_equal TestReturnFromNestedBlock_BSBlock35.test, :ok
end
diff --git a/test/t/bs_literal.rb b/test/t/bs_literal.rb
index 842d8704c..c6c38140b 100644
--- a/test/t/bs_literal.rb
+++ b/test/t/bs_literal.rb
@@ -2,37 +2,37 @@
# Bootstrap test for literals
assert('BS Literal 1') do
- true == true
+ assert_true true
end
assert('BS Literal 2') do
- TrueClass == true.class
+ assert_equal TrueClass, true.class
end
assert('BS Literal 3') do
- false == false
+ assert_false false
end
assert('BS Literal 4') do
- FalseClass == false.class
+ assert_equal FalseClass, false.class
end
assert('BS Literal 5') do
- 'nil' == nil.inspect
+ assert_equal 'nil', nil.inspect
end
assert('BS Literal 6') do
- NilClass == nil.class
+ assert_equal NilClass, nil.class
end
assert('BS Literal 7') do
- Symbol == :sym.class
+ assert_equal Symbol, :sym.class
end
assert('BS Literal 8') do
- 1234 == 1234
+ assert_equal 1234, 1234
end
assert('BS Literal 9') do
- Fixnum == 1234.class
+ assert_equal Fixnum, 1234.class
end
diff --git a/test/t/float.rb b/test/t/float.rb
index abb5cf2e7..97399b76f 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
diff --git a/test/t/gc.rb b/test/t/gc.rb
index 410272797..4a1bd0c1a 100644
--- a/test/t/gc.rb
+++ b/test/t/gc.rb
@@ -1,15 +1,15 @@
# Not ISO specified
assert('GC.enable') do
- GC.disable == false
- GC.enable == true
- GC.enable == false
+ assert_equal GC.disable, false
+ assert_equal GC.enable, true
+ assert_equal GC.enable, false
end
assert('GC.disable') do
begin
- GC.disable == false
- GC.disable == true
+ assert_equal GC.disable, false
+ assert_equal GC.disable, true
ensure
GC.enable
end
@@ -18,7 +18,7 @@ end
assert('GC.interval_ratio=') do
origin = GC.interval_ratio
begin
- (GC.interval_ratio = 150) == 150
+ assert_equal (GC.interval_ratio = 150), 150
ensure
GC.interval_ratio = origin
end
@@ -27,7 +27,7 @@ end
assert('GC.step_ratio=') do
origin = GC.step_ratio
begin
- (GC.step_ratio = 150) == 150
+ assert_equal (GC.step_ratio = 150), 150
ensure
GC.step_ratio = origin
end
@@ -36,9 +36,9 @@ end
assert('GC.generational_mode=') do
origin = GC.generational_mode
begin
- (GC.generational_mode = false) == false
- (GC.generational_mode = true) == true
- (GC.generational_mode = true) == true
+ assert_equal (GC.generational_mode = false), false
+ assert_equal (GC.generational_mode = true), true
+ assert_equal (GC.generational_mode = true), true
ensure
GC.generational_mode = origin
end
diff --git a/test/t/indexerror.rb b/test/t/indexerror.rb
index d7c8ba148..b71766c95 100644
--- a/test/t/indexerror.rb
+++ b/test/t/indexerror.rb
@@ -2,10 +2,9 @@
# IndexError ISO Test
assert('IndexError', '15.2.33') do
- IndexError.class == Class
+ assert_equal IndexError.class, Class
end
assert('IndexError superclass', '15.2.33.2') do
- IndexError.superclass == StandardError
+ assert_equal IndexError.superclass, StandardError
end
-
diff --git a/test/t/literals.rb b/test/t/literals.rb
index f40852ff9..1e4c3a31c 100644
--- a/test/t/literals.rb
+++ b/test/t/literals.rb
@@ -14,7 +14,7 @@ assert('Literals Numerical', '8.7.6.2') do
0xff == 255 and 0Xff == 255 and
# decimal
0d999 == 999 and 0D999 == 999 and
- # decimal seperator
+ # decimal separator
10_000_000 == 10000000 and 1_0 == 10 and
# integer with exponent
1e1 == 10.0 and 1e-1 == 0.1 and 1e+1 == 10.0
diff --git a/test/t/localjumperror.rb b/test/t/localjumperror.rb
index ebcec0670..857b0ce65 100644
--- a/test/t/localjumperror.rb
+++ b/test/t/localjumperror.rb
@@ -1,13 +1,12 @@
##
# LocalJumpError ISO Test
-assert('LocalJumoError', '15.2.25') do
- begin
+assert('LocalJumpError', '15.2.25') do
+ assert_equal LocalJumpError.class, Class
+ assert_raise LocalJumpError do
# this will cause an exception due to the wrong location
retry
- rescue => e1
end
- LocalJumpError.class == Class and e1.class == LocalJumpError
end
# TODO 15.2.25.2.1 LocalJumpError#exit_value
diff --git a/test/t/nameerror.rb b/test/t/nameerror.rb
index 30da74a15..8b54f3c52 100644
--- a/test/t/nameerror.rb
+++ b/test/t/nameerror.rb
@@ -2,11 +2,11 @@
# NameError ISO Test
assert('NameError', '15.2.31') do
- NameError.class == Class
+ assert_equal NameError.class, Class
end
assert('NameError superclass', '15.2.31.2') do
- NameError.superclass == StandardError
+ assert_equal NameError.superclass, StandardError
end
assert('NameError#name', '15.2.31.2.1') do
@@ -20,13 +20,13 @@ assert('NameError#name', '15.2.31.2.1') do
$test_dummy_result = e.name
end
- $test_dummy_result == :bar
+ assert_equal $test_dummy_result, :bar
end
assert('NameError#initialize', '15.2.31.2.2') do
e = NameError.new('a', :foo)
- e.class == NameError and
- e.message == 'a' and
- e.name == :foo
+ assert_equal e.class, NameError
+ assert_equal e.message, 'a'
+ assert_equal e.name, :foo
end
diff --git a/test/t/nil.rb b/test/t/nil.rb
index 8f1393e1b..99b1215e9 100644
--- a/test/t/nil.rb
+++ b/test/t/nil.rb
@@ -2,25 +2,29 @@
# NilClass ISO Test
assert('NilClass', '15.2.4') do
- NilClass.class == Class
+ assert_equal NilClass.class, Class
end
assert('NilClass#&', '15.2.4.3.1') do
- not nil.&(true) and not nil.&(nil)
+ assert_false nil.&(true)
+ assert_false nil.&(nil)
end
assert('NilClass#^', '15.2.4.3.2') do
- nil.^(true) and not nil.^(false)
+ assert_true nil.^(true)
+ assert_false nil.^(false)
end
assert('NilClass#|', '15.2.4.3.3') do
- nil.|(true) and not nil.|(false)
+ assert_true nil.|(true)
+ assert_false nil.|(false)
end
assert('NilClass#nil?', '15.2.4.3.4') do
- nil.nil?
+ assert_true nil.nil?
end
assert('NilClass#to_s', '15.2.4.3.5') do
- nil.to_s == ''
+ assert_equal nil.to_s, ''
end
+
diff --git a/test/t/nomethoderror.rb b/test/t/nomethoderror.rb
index caab04a41..2b1ac8e88 100644
--- a/test/t/nomethoderror.rb
+++ b/test/t/nomethoderror.rb
@@ -2,17 +2,12 @@
# NoMethodError ISO Test
assert('NoMethodError', '15.2.32') do
- e2 = nil
- begin
+ NoMethodError.class == Class
+ assert_raise NoMethodError do
doesNotExistAsAMethodNameForVerySure("")
- rescue => e1
- e2 = e1
end
-
- NoMethodError.class == Class and e2.class == NoMethodError
end
assert('NoMethodError superclass', '15.2.32.2') do
- NoMethodError.superclass == NameError
+ assert_equal NoMethodError.superclass, NameError
end
-
diff --git a/test/t/numeric.rb b/test/t/numeric.rb
index 3cdb9a8cf..1fa92b662 100644
--- a/test/t/numeric.rb
+++ b/test/t/numeric.rb
@@ -2,27 +2,28 @@
# Numeric ISO Test
assert('Numeric', '15.2.7') do
- Numeric.class == Class
+ assert_equal Numeric.class, Class
end
assert('Numeric superclass', '15.2.7.2') do
- Numeric.superclass == Object
+ assert_equal Numeric.superclass, Object
end
assert('Numeric#+@', '15.2.7.4.1') do
- +1 == +1
+ assert_equal(+1, +1)
end
assert('Numeric#-@', '15.2.7.4.2') do
- -1 == -1
+ assert_equal(-1, -1)
end
assert('Numeric#abs', '15.2.7.4.3') do
- 1.abs == 1 and -1.abs == 1.0
+ assert_equal(1.abs, 1)
+ assert_equal(-1.abs, 1.0)
end
# Not ISO specified
assert('Numeric#**') do
- 2.0**3 == 8.0
+ assert_equal 2.0**3, 8.0
end
diff --git a/test/t/object.rb b/test/t/object.rb
index 7dfaf6589..2586f1761 100644
--- a/test/t/object.rb
+++ b/test/t/object.rb
@@ -2,10 +2,10 @@
# Object ISO Test
assert('Object', '15.2.1') do
- Object.class == Class
+ assert_equal Object.class, Class
end
assert('Object superclass', '15.2.1.2') do
- Object.superclass == BasicObject
+ assert_equal Object.superclass, BasicObject
end
diff --git a/test/t/proc.rb b/test/t/proc.rb
index 4d5e5cab4..56bab8c64 100644
--- a/test/t/proc.rb
+++ b/test/t/proc.rb
@@ -2,25 +2,19 @@
# Proc ISO Test
assert('Proc', '15.2.17') do
- Proc.class == Class
+ assert_equal Proc.class, Class
end
assert('Proc superclass', '15.2.17.2') do
- Proc.superclass == Object
+ assert_equal Proc.superclass, Object
end
assert('Proc.new', '15.2.17.3.1') do
- a = nil
-
- begin
+ assert_raise ArgumentError do
Proc.new
- rescue => e
- a = e
end
- b = Proc.new {}
-
- a.class == ArgumentError and b.class == Proc
+ assert_equal (Proc.new {}).class, Proc
end
assert('Proc#[]', '15.2.17.4.1') do
@@ -32,7 +26,8 @@ assert('Proc#[]', '15.2.17.4.1') do
b2 = Proc.new { |i| a2 += i }
b2.[](5)
- a == 1 and a2 == 5
+ assert_equal a, 1
+ assert_equal a2, 5
end
assert('Proc#arity', '15.2.17.4.2') do
@@ -41,7 +36,10 @@ assert('Proc#arity', '15.2.17.4.2') do
c = Proc.new {|x=0, y|}.arity
d = Proc.new {|(x, y), z=0|}.arity
- a == 2 and b == -3 and c == 1 and d == 1
+ assert_equal a, 2
+ assert_equal b, -3
+ assert_equal c, 1
+ assert_equal d, 1
end
assert('Proc#call', '15.2.17.4.3') do
@@ -53,5 +51,6 @@ assert('Proc#call', '15.2.17.4.3') do
b2 = Proc.new { |i| a2 += i }
b2.call(5)
- a == 1 and a2 == 5
+ assert_equal a, 1
+ assert_equal a2, 5
end
diff --git a/test/t/rangeerror.rb b/test/t/rangeerror.rb
index 57afdc4bd..2a15ce225 100644
--- a/test/t/rangeerror.rb
+++ b/test/t/rangeerror.rb
@@ -2,10 +2,9 @@
# RangeError ISO Test
assert('RangeError', '15.2.26') do
- RangeError.class == Class
+ assert_equal RangeError.class, Class
end
assert('RangeError superclass', '15.2.26.2') do
- RangeError.superclass == StandardError
+ assert_equal RangeError.superclass, StandardError
end
-
diff --git a/test/t/runtimeerror.rb b/test/t/runtimeerror.rb
index 3e0636186..b8d64a726 100644
--- a/test/t/runtimeerror.rb
+++ b/test/t/runtimeerror.rb
@@ -2,5 +2,5 @@
# RuntimeError ISO Test
assert('RuntimeError', '15.2.28') do
- RuntimeError.class == Class
+ assert_equal RuntimeError.class, Class
end
diff --git a/test/t/standarderror.rb b/test/t/standarderror.rb
index 3868d7567..42b06d911 100644
--- a/test/t/standarderror.rb
+++ b/test/t/standarderror.rb
@@ -2,10 +2,9 @@
# StandardError ISO Test
assert('StandardError', '15.2.23') do
- StandardError.class == Class
+ assert_equal StandardError.class, Class
end
assert('StandardError superclass', '15.2.23.2') do
- StandardError.superclass == Exception
+ assert_equal StandardError.superclass, Exception
end
-
diff --git a/test/t/symbol.rb b/test/t/symbol.rb
index b28573e92..e4ced61e0 100644
--- a/test/t/symbol.rb
+++ b/test/t/symbol.rb
@@ -2,25 +2,26 @@
# Symbol ISO Test
assert('Symbol', '15.2.11') do
- Symbol.class == Class
+ assert_equal Symbol.class, Class
end
assert('Symbol superclass', '15.2.11.2') do
- Symbol.superclass == Object
+ assert_equal Symbol.superclass, Object
end
assert('Symbol#===', '15.2.11.3.1') do
- :abc === :abc and not :abc === :cba
+ assert_true :abc == :abc
+ assert_false :abc == :cba
end
assert('Symbol#id2name', '15.2.11.3.2') do
- :abc.id2name == 'abc'
+ assert_equal :abc.id2name, 'abc'
end
assert('Symbol#to_s', '15.2.11.3.3') do
- :abc.to_s == 'abc'
+ assert_equal :abc.to_s, 'abc'
end
assert('Symbol#to_sym', '15.2.11.3.4') do
- :abc.to_sym == :abc
+ assert_equal :abc.to_sym, :abc
end
diff --git a/test/t/true.rb b/test/t/true.rb
index ae83e0baa..9ea68f81b 100644
--- a/test/t/true.rb
+++ b/test/t/true.rb
@@ -2,29 +2,32 @@
# TrueClass ISO Test
assert('TrueClass', '15.2.5') do
- TrueClass.class == Class
+ assert_equal TrueClass.class, Class
end
assert('TrueClass superclass', '15.2.5.2') do
- TrueClass.superclass == Object
+ assert_equal TrueClass.superclass, Object
end
assert('TrueClass true', '15.2.5.1') do
- true
+ assert_true true
end
assert('TrueClass#&', '15.2.5.3.1') do
- true.&(true) and not true.&(false)
+ assert_true true.&(true)
+ assert_false true.&(false)
end
assert('TrueClass#^', '15.2.5.3.2') do
- not true.^(true) and true.^(false)
+ assert_false true.^(true)
+ assert_true true.^(false)
end
assert('TrueClass#to_s', '15.2.5.3.3') do
- true.to_s == 'true'
+ assert_equal true.to_s, 'true'
end
assert('TrueClass#|', '15.2.5.3.4') do
- true.|(true) and true.|(false)
+ assert_true true.|(true)
+ assert_true true.|(false)
end
diff --git a/test/t/typeerror.rb b/test/t/typeerror.rb
index d48db111a..59c3ea993 100644
--- a/test/t/typeerror.rb
+++ b/test/t/typeerror.rb
@@ -2,10 +2,10 @@
# TypeError ISO Test
assert('TypeError', '15.2.29') do
- TypeError.class == Class
+ assert_equal TypeError.class, Class
end
assert('TypeError superclass', '15.2.29.2') do
- TypeError.superclass == StandardError
+ assert_equal TypeError.superclass, StandardError
end