From dfd39f0b14794b360fd6c961c65ab45d229e00b1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 22 Jul 2018 13:59:08 -0700 Subject: Shifting further towards having inline tests. Also added a helper function for directly extracting source lines from a Source or AST. --- core/coroutines.nom | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'core/coroutines.nom') 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 -- cgit v1.2.3