Commit 2d25a15b authored by take_cheeze's avatar take_cheeze

Use `assert_*` method instead of using result value.

Use `do ... end` for test block.
parent 229e7fe2
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]
......
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