diff options
Diffstat (limited to 'unit_tests/scripts/_utils.lua')
-rw-r--r-- | unit_tests/scripts/_utils.lua | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/unit_tests/scripts/_utils.lua b/unit_tests/scripts/_utils.lua index d710702..9f46237 100644 --- a/unit_tests/scripts/_utils.lua +++ b/unit_tests/scripts/_utils.lua | |||
@@ -68,8 +68,26 @@ local function dump_error_stack(error_reporting_mode_, stack) | |||
68 | end | 68 | end |
69 | end | 69 | end |
70 | 70 | ||
71 | -- a function that yields back what got in, one element at a time | ||
72 | local yield_one_by_one = function(...) | ||
73 | local PRINT = MAKE_PRINT() | ||
74 | PRINT "In lane" | ||
75 | for _i = 1, select('#', ...) do | ||
76 | local _val = select(_i, ...) | ||
77 | PRINT("yielding #", _i, _val) | ||
78 | local _ack = coroutine.yield(_val) | ||
79 | if cancel_test and cancel_test() then -- cancel_test does not exist when run immediately (not in a Lane) | ||
80 | return "cancelled!" | ||
81 | end | ||
82 | -- of course, if we are cancelled, we were not resumed, and yield() didn't return what we expect | ||
83 | assert(_ack == _i) | ||
84 | end | ||
85 | return "bye!" | ||
86 | end | ||
87 | |||
71 | return { | 88 | return { |
72 | MAKE_PRINT = MAKE_PRINT, | 89 | MAKE_PRINT = MAKE_PRINT, |
73 | tables_match = tables_match, | 90 | tables_match = tables_match, |
74 | dump_error_stack = dump_error_stack | 91 | dump_error_stack = dump_error_stack, |
92 | yield_one_by_one = yield_one_by_one | ||
75 | } | 93 | } |