# HG changeset patch # User Kim Alvefur # Date 1647519350 -3600 # Node ID 728d1c1dc7db6fca1381ccd832aa4a02aa92cffa # Parent d99772b739e0d2dfd9c4abaf3492d1b7594e46ab util.poll: Expand stub tests Because tests good. diff -r d99772b739e0 -r 728d1c1dc7db spec/util_poll_spec.lua --- a/spec/util_poll_spec.lua Thu Mar 17 10:24:38 2022 +0000 +++ b/spec/util_poll_spec.lua Thu Mar 17 13:15:50 2022 +0100 @@ -1,6 +1,35 @@ -describe("util.poll", function () - it("loads", function () - require "util.poll" +describe("util.poll", function() + local poll; + setup(function() + poll = require "util.poll"; + end); + it("loads", function() + assert.is_table(poll); + assert.is_function(poll.new); + assert.is_string(poll.api); end); + describe("new", function() + local p; + setup(function() + p = poll.new(); + end) + it("times out", function () + local fd, err = p:wait(0); + assert.falsy(fd); + assert.equal("timeout", err); + end); + it("works", function() + -- stdout should be writable, right? + assert.truthy(p:add(1, false, true)); + local fd, r, w = p:wait(1); + assert.is_number(fd); + assert.is_boolean(r); + assert.is_boolean(w); + assert.equal(1, fd); + assert.falsy(r); + assert.truthy(w); + assert.truthy(p:del(1)); + end); + end) end);