Commit 6cf5618b authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge branch 'master' of github.com:mruby/mruby

parents 6d695707 84116c26
assert('Fiber.new') { assert('Fiber.new') do
f = Fiber.new{} f = Fiber.new{}
f.class == Fiber assert_kind_of Fiber, f
} end
assert('Fiber#resume') { assert('Fiber#resume') do
f = Fiber.new{|x| x == 2} f = Fiber.new{|x| x }
f.resume(2) assert_equal 2, f.resume(2)
} end
assert('Fiber#transfer') do assert('Fiber#transfer') do
f2 = nil f2 = nil
...@@ -29,14 +29,13 @@ assert('Fiber#transfer') do ...@@ -29,14 +29,13 @@ assert('Fiber#transfer') do
assert_false f2.alive? assert_false f2.alive?
end end
assert('Fiber#alive?') { assert('Fiber#alive?') do
f = Fiber.new{ Fiber.yield } f = Fiber.new{ Fiber.yield }
f.resume f.resume
r1 = f.alive? assert_true f.alive?
f.resume f.resume
r2 = f.alive? assert_false f.alive?
r1 == true and r2 == false end
}
assert('Fiber#==') do assert('Fiber#==') do
root = Fiber.current root = Fiber.current
...@@ -51,16 +50,17 @@ assert('Fiber#==') do ...@@ -51,16 +50,17 @@ assert('Fiber#==') do
assert_true f != root assert_true f != root
end end
assert('Fiber.yield') { assert('Fiber.yield') do
f = Fiber.new{|x| Fiber.yield(x == 3)} f = Fiber.new{|x| Fiber.yield x }
f.resume(3) assert_equal 3, f.resume(3)
} assert_true f.alive?
end
assert('FiberError') do assert('FiberError') do
assert_equal StandardError, FiberError.superclass assert_equal StandardError, FiberError.superclass
end end
assert('Fiber iteration') { assert('Fiber iteration') do
f1 = Fiber.new{ f1 = Fiber.new{
[1,2,3].each{|x| Fiber.yield(x)} [1,2,3].each{|x| Fiber.yield(x)}
} }
...@@ -72,8 +72,8 @@ assert('Fiber iteration') { ...@@ -72,8 +72,8 @@ assert('Fiber iteration') {
a << f1.resume a << f1.resume
a << f2.resume a << f2.resume
} }
a == [1,9,2,8,3,7] assert_equal [1,9,2,8,3,7], a
} end
assert('Fiber with splat in the block argument list') { assert('Fiber with splat in the block argument list') {
Fiber.new{|*x|x}.resume(1) == [1] Fiber.new{|*x|x}.resume(1) == [1]
......
...@@ -10,7 +10,7 @@ end ...@@ -10,7 +10,7 @@ end
assert('Proc#inspect') do assert('Proc#inspect') do
ins = Proc.new{}.inspect ins = Proc.new{}.inspect
assert_true ins.kind_of? String assert_kind_of String, ins
end end
assert('Proc#lambda?') do assert('Proc#lambda?') do
......
...@@ -44,7 +44,7 @@ assert('Enumerable#collect', '15.3.2.2.3') do ...@@ -44,7 +44,7 @@ assert('Enumerable#collect', '15.3.2.2.3') do
end end
assert('Enumerable#detect', '15.3.2.2.4') do assert('Enumerable#detect', '15.3.2.2.4') do
assert_true [1,2,3].detect() { true } assert_equal 1, [1,2,3].detect() { true }
assert_equal 'a', [1,2,3].detect("a") { false } assert_equal 'a', [1,2,3].detect("a") { false }
end end
...@@ -63,7 +63,7 @@ assert('Enumerable#entries', '15.3.2.2.6') do ...@@ -63,7 +63,7 @@ assert('Enumerable#entries', '15.3.2.2.6') do
end end
assert('Enumerable#find', '15.3.2.2.7') do assert('Enumerable#find', '15.3.2.2.7') do
assert_true [1,2,3].find() { true } assert_equal 1, [1,2,3].find() { true }
assert_equal 'a', [1,2,3].find("a") { false } assert_equal 'a', [1,2,3].find("a") { false }
end end
...@@ -106,7 +106,7 @@ assert('Enumerable#member?', '15.3.2.2.15') do ...@@ -106,7 +106,7 @@ assert('Enumerable#member?', '15.3.2.2.15') do
assert_false [1,2,3,4,5,6,7,8,9].member?(0) assert_false [1,2,3,4,5,6,7,8,9].member?(0)
end end
assert('Enumerable#partion', '15.3.2.2.16') do assert('Enumerable#partition', '15.3.2.2.16') do
[0,1,2,3,4,5,6,7,8,9].partition do |i| [0,1,2,3,4,5,6,7,8,9].partition do |i|
i % 2 == 0 i % 2 == 0
end == [[0,2,4,6,8], [1,3,5,7,9]] end == [[0,2,4,6,8], [1,3,5,7,9]]
......
...@@ -16,11 +16,14 @@ assert('Exception.exception', '15.2.22.4.1') do ...@@ -16,11 +16,14 @@ assert('Exception.exception', '15.2.22.4.1') do
end end
assert('Exception#exception', '15.2.22.5.1') do assert('Exception#exception', '15.2.22.5.1') do
e1 = Exception.exception() e = Exception.new
e2 = Exception.exception('b') re = RuntimeError.new
assert_equal e, e.exception
assert_equal Exception, e1.class assert_equal e, e.exception(e)
assert_equal Exception, e2.class assert_equal re, re.exception(re)
changed_re = re.exception('message has changed')
assert_not_equal re, changed_re
assert_equal 'message has changed', changed_re.message
end end
assert('Exception#message', '15.2.22.5.2') do assert('Exception#message', '15.2.22.5.2') do
......
...@@ -26,8 +26,8 @@ assert('Proc#[]', '15.2.17.4.1') do ...@@ -26,8 +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)
assert_equal a, 1 assert_equal 1, a
assert_equal a2, 5 assert_equal 5, a2
end end
assert('Proc#arity', '15.2.17.4.2') do assert('Proc#arity', '15.2.17.4.2') do
......
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