feat: add fiber.isDone property and runtime error checks for finished fiber operations

Add a new `isDone` native method to the Fiber class that returns true when the fiber has no remaining frames. Replace TODO comments with proper runtime error handling in `fiber_run`, `fiber_run1`, `fiber_yield`, and `fiber_yield1` to prevent running finished fibers or yielding from the main fiber. Include test cases verifying the new property and error conditions.
This commit is contained in:
Bob Nystrom
2014-01-13 14:58:27 +00:00
parent 8cee1f62bd
commit 8abfb4ec7d
6 changed files with 38 additions and 4 deletions
+11
View File
@@ -0,0 +1,11 @@
var fiber = Fiber.create(fn {
IO.print("1")
Fiber.yield
IO.print("2")
})
IO.print(fiber.isDone) // expect: false
fiber.run // expect: 1
IO.print(fiber.isDone) // expect: false
fiber.run // expect: 2
IO.print(fiber.isDone) // expect: true