aboutsummaryrefslogtreecommitdiff
path: root/core/coroutines.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-22 13:59:08 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-22 13:59:08 -0700
commitdfd39f0b14794b360fd6c961c65ab45d229e00b1 (patch)
tree51f0c30ef3a32c969c63321da8164436a3ba8b31 /core/coroutines.nom
parent01d5f810ed7fd6e9b261b1fe793f8666970b2068 (diff)
Shifting further towards having inline tests. Also added a helper
function for directly extracting source lines from a Source or AST.
Diffstat (limited to 'core/coroutines.nom')
-rw-r--r--core/coroutines.nom13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/coroutines.nom b/core/coroutines.nom
index 52467c1..6e7d9e3 100644
--- a/core/coroutines.nom
+++ b/core/coroutines.nom
@@ -4,6 +4,17 @@
use "core/metaprogramming.nom"
+test:
+ %nums = []
+ %co = (..)
+ coroutine:
+ -> 4
+ -> 5
+ repeat 3 times: -> 6
+
+ for % in coroutine %co: add % to %nums
+ assume (%nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed"
+
compile [coroutine %body, generator %body] to (..)
Lua value ".."
(function()
@@ -16,4 +27,4 @@ compile [for % in coroutine %co %body] to (..)
Lua ".."
for junk,\(% as lua expr) in coroutine.wrap(\(%co as lua expr)) do
\(%body as lua statements)
- end \ No newline at end of file
+ end