More fiber tests.

This commit is contained in:
Bob Nystrom
2014-02-14 07:16:56 -08:00
parent ca4f4d6660
commit edd360a934
4 changed files with 34 additions and 13 deletions

25
test/fiber/closure.wren Normal file
View File

@ -0,0 +1,25 @@
var fiber
var closure
{
var a = "before"
fiber = Fiber.create(fn {
IO.print(a)
Fiber.yield
a = "after"
Fiber.yield
IO.print(a)
a = "final"
})
closure = fn {
IO.print(a)
}
}
fiber.run // expect: before
closure.call // expect: before
fiber.run
closure.call // expect: after
fiber.run // expect: after
closure.call // expect: final

View File

@ -0,0 +1 @@
var fiber = Fiber.create("not fn") // expect runtime error: Argument must be a function.

View File

@ -7,6 +7,3 @@ fiber.run // expect: fiber
IO.print("after") // expect: after
// TODO: Test handles error if fiber tries to run itself.
// TODO: Test create is passed right argument type.
// TODO: Test closing over stuff in fiber function.
// TODO: Test running a finished fiber.