diff options
| author | William Boman <william@redwill.se> | 2022-07-06 19:41:43 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2022-07-07 00:39:59 +0200 |
| commit | 5f634e0c37e723fc0c33e06b4fd5c2180178db40 (patch) | |
| tree | fa4f09363adefa8259e23e4d1ea036db628b1243 /tests/core/async_spec.lua | |
| parent | feat(health): use stderr for java version, also check for JAVA_HOME (#765) (diff) | |
| download | mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.gz mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.bz2 mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.lz mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.xz mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.zst mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.zip | |
mason.nvim
Diffstat (limited to 'tests/core/async_spec.lua')
| -rw-r--r-- | tests/core/async_spec.lua | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/core/async_spec.lua b/tests/core/async_spec.lua index ce55c5ab..330a014e 100644 --- a/tests/core/async_spec.lua +++ b/tests/core/async_spec.lua @@ -1,8 +1,8 @@ local assert = require "luassert" local spy = require "luassert.spy" local match = require "luassert.match" -local a = require "nvim-lsp-installer.core.async" -local process = require "nvim-lsp-installer.core.process" +local a = require "mason.core.async" +local process = require "mason.core.process" local function timestamp() local seconds, microseconds = vim.loop.gettimeofday() @@ -169,4 +169,31 @@ describe("async", function() assert.equals(5, five) end) ) + + it( + "should run all suspending functions concurrently", + async_test(function() + local start = timestamp() + local called = spy.new() + local function sleep(ms, ret_val) + return function() + a.sleep(ms) + called() + return ret_val + end + end + local first = a.wait_first { + sleep(150, 1), + sleep(50, "first"), + sleep(150, "three"), + sleep(150, 4), + sleep(150, 5), + } + local grace = 50 + local delta = timestamp() - start + assert.is_true(delta <= (100 + grace)) + assert.is_true(delta >= (100 - grace)) + assert.equals("first", first) + end) + ) end) |
