Commit 9166a135 authored by Daniel Bovensiepen's avatar Daniel Bovensiepen

Improve Proc Tests

parent e44ba316
...@@ -2,25 +2,19 @@ ...@@ -2,25 +2,19 @@
# Proc ISO Test # Proc ISO Test
assert('Proc', '15.2.17') do assert('Proc', '15.2.17') do
Proc.class == Class assert_equal Proc.class, Class
end end
assert('Proc superclass', '15.2.17.2') do assert('Proc superclass', '15.2.17.2') do
Proc.superclass == Object assert_equal Proc.superclass, Object
end end
assert('Proc.new', '15.2.17.3.1') do assert('Proc.new', '15.2.17.3.1') do
a = nil assert_raise ArgumentError do
begin
Proc.new Proc.new
rescue => e
a = e
end end
b = Proc.new {} assert_equal (Proc.new {}).class, Proc
a.class == ArgumentError and b.class == Proc
end end
assert('Proc#[]', '15.2.17.4.1') do assert('Proc#[]', '15.2.17.4.1') do
...@@ -32,7 +26,8 @@ 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 = Proc.new { |i| a2 += i }
b2.[](5) b2.[](5)
a == 1 and a2 == 5 assert_equal a, 1
assert_equal a2, 5
end end
assert('Proc#arity', '15.2.17.4.2') do assert('Proc#arity', '15.2.17.4.2') do
...@@ -41,7 +36,10 @@ 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 c = Proc.new {|x=0, y|}.arity
d = Proc.new {|(x, y), z=0|}.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 end
assert('Proc#call', '15.2.17.4.3') do assert('Proc#call', '15.2.17.4.3') do
...@@ -53,5 +51,6 @@ 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 = Proc.new { |i| a2 += i }
b2.call(5) b2.call(5)
a == 1 and a2 == 5 assert_equal a, 1
assert_equal a2, 5
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment