diff options
| author | William Boman <william@redwill.se> | 2022-04-16 01:43:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-16 01:43:09 +0200 |
| commit | c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5 (patch) | |
| tree | 0956a0e6f3b931921563eae6265abd3bad481d9b /tests/core/async/async_spec.lua | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.gz mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.bz2 mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.lz mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.xz mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.tar.zst mason-c472f3ea46a5dd5f62bb12b5857e779ae0d74dc5.zip | |
fix(async): slightly better support for nested coroutine contexts (#600)
* fix(async): only dispatch first failure in a.wait_all
* add InstallContext:run_concurrently
This is needed due to how multiple coroutine contexts are used in a hierchical
structure, and the async coroutine dispatcher loses this hierchical context
inside callback functions invoked via FFI (I… assume?).
Diffstat (limited to 'tests/core/async/async_spec.lua')
| -rw-r--r-- | tests/core/async/async_spec.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/core/async/async_spec.lua b/tests/core/async/async_spec.lua index 9795adce..c0e8992e 100644 --- a/tests/core/async/async_spec.lua +++ b/tests/core/async/async_spec.lua @@ -136,22 +136,28 @@ describe("async", function() "should run all suspending functions concurrently", async_test(function() local start = timestamp() - local function sleep(ms) + local function sleep(ms, ret_val) return function() a.sleep(ms) + return ret_val end end - a.wait_all { - sleep(100), - sleep(100), - sleep(100), - sleep(100), - sleep(100), + local one, two, three, four, five = a.wait_all { + sleep(100, 1), + sleep(100, "two"), + sleep(100, "three"), + sleep(100, 4), + sleep(100, 5), } local grace = 50 local delta = timestamp() - start assert.is_true(delta <= (100 + grace)) assert.is_true(delta >= (100 - grace)) + assert.equals(1, one) + assert.equals("two", two) + assert.equals("three", three) + assert.equals(4, four) + assert.equals(5, five) end) ) end) |
