fix: close upvalues before fiber completion and add closure tests

Move upvalue closing logic from the else branch to before the fiber completion check
to ensure upvalues are properly closed when a fiber finishes. Add test cases for
closure behavior across fiber yields and for Fiber.create argument type validation.
This commit is contained in:
Bob Nystrom
2014-02-14 15:16:56 +00:00
parent 00239d37b2
commit 04cb19c605
4 changed files with 34 additions and 13 deletions
+25
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