Comparison

spec/util_async_spec.lua @ 8624:5325f0e1791b

util.async: tests: Ensure done() can be called before wait()
author Matthew Wild <mwild1@gmail.com>
date Sat, 17 Mar 2018 18:23:39 +0000
parent 8623:ab242c513bf4
child 8628:e88744fa0985
comparison
equal deleted inserted replaced
8623:ab242c513bf4 8624:5325f0e1791b
531 assert.equal(r1.state, "ready"); 531 assert.equal(r1.state, "ready");
532 532
533 assert.equal(r1.state, "ready"); 533 assert.equal(r1.state, "ready");
534 --for k, v in ipairs(l1) do print(k,v) end 534 --for k, v in ipairs(l1) do print(k,v) end
535 end); 535 end);
536
537 it("should allow done() to be called before wait()", function ()
538 local processed_item;
539 local rf = spy.new(function (item)
540 local wait, done = async.waiter();
541 done();
542 wait();
543 processed_item = item;
544 end);
545 local r = async.runner(rf, mock_watchers());
546 r:run("test");
547 assert.equal(processed_item, "test");
548 assert.equal(r.state, "ready");
549 -- Since the observable state did not change,
550 -- the watchers should not have been called
551 assert.spy(r.watchers.waiting).was_not.called();
552 assert.spy(r.watchers.ready).was_not.called();
553 end);
536 end); 554 end);
537 end); 555 end);