Mercurial > prosody-hg
comparison spec/util_async_spec.lua @ 8648:ca710a71d730
util.async: Add ready() to check whether running in async context
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 22 Mar 2018 07:46:23 +0000 |
| parents | 8ec18a002c30 |
| children | 9246f64d6f1e |
comparison
equal
deleted
inserted
replaced
| 8647:638ff2ad98e6 | 8648:ca710a71d730 |
|---|---|
| 577 -- the watchers should not have been called | 577 -- the watchers should not have been called |
| 578 assert.spy(r.watchers.waiting).was_not.called(); | 578 assert.spy(r.watchers.waiting).was_not.called(); |
| 579 assert.spy(r.watchers.ready).was_not.called(); | 579 assert.spy(r.watchers.ready).was_not.called(); |
| 580 end); | 580 end); |
| 581 end); | 581 end); |
| 582 | |
| 583 describe("#ready()", function () | |
| 584 it("should return false outside an async context", function () | |
| 585 assert.falsy(async.ready()); | |
| 586 end); | |
| 587 it("should return true inside an async context", function () | |
| 588 local r = new(function () | |
| 589 assert.truthy(async.ready()); | |
| 590 end); | |
| 591 r:run(true); | |
| 592 assert.spy(r.func).was.called(); | |
| 593 assert.spy(r.watchers.error).was_not.called(); | |
| 594 end); | |
| 595 end); | |
| 582 end); | 596 end); |
