diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2025-04-07 10:43:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-07 10:43:30 +0200 |
| commit | 49e7dac558178e6200bc5886db3ef28c73d5edd9 (patch) | |
| tree | df5ef51d0e1196895c3cc8bf73453b56133747ad /spec | |
| parent | 95cd4af3fb48f020af821aeccc98563561569de2 (diff) | |
| download | luasystem-49e7dac558178e6200bc5886db3ef28c73d5edd9.tar.gz luasystem-49e7dac558178e6200bc5886db3ef28c73d5edd9.tar.bz2 luasystem-49e7dac558178e6200bc5886db3ef28c73d5edd9.zip | |
fix(readkey): if sleep fails return the error (#60)
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/04-term_spec.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/04-term_spec.lua b/spec/04-term_spec.lua index 907f903..b3de461 100644 --- a/spec/04-term_spec.lua +++ b/spec/04-term_spec.lua | |||
| @@ -855,6 +855,32 @@ describe("Terminal:", function() | |||
| 855 | assert.is.near(1, timing, 0.5) -- this also works for MacOS in CI | 855 | assert.is.near(1, timing, 0.5) -- this also works for MacOS in CI |
| 856 | end) | 856 | end) |
| 857 | 857 | ||
| 858 | |||
| 859 | it("calls flseep to execute the sleep", function() | ||
| 860 | setbuffer("") | ||
| 861 | |||
| 862 | local sleep_called = false | ||
| 863 | local mysleep = function() | ||
| 864 | sleep_called = true | ||
| 865 | end | ||
| 866 | |||
| 867 | system.readkey(0.01, mysleep) | ||
| 868 | assert.is_true(sleep_called) | ||
| 869 | end) | ||
| 870 | |||
| 871 | |||
| 872 | it("returns errors by fsleep", function() | ||
| 873 | setbuffer("") | ||
| 874 | |||
| 875 | local mysleep = function() | ||
| 876 | return nil, "boom!" | ||
| 877 | end | ||
| 878 | |||
| 879 | local ok, err = system.readkey(1, mysleep) | ||
| 880 | assert.is.falsy(ok) | ||
| 881 | assert.equals("boom!", err) | ||
| 882 | end) | ||
| 883 | |||
| 858 | end) | 884 | end) |
| 859 | 885 | ||
| 860 | 886 | ||
