Skip to content

Commit 63a23db

Browse files
committed
xxxx
1 parent c133fb0 commit 63a23db

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

tests/lapi/coroutine_test.lua

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@ https://www.lua.org/bugs.html#5.0.2-3
5050
Attempt to resume a running coroutine crashes Lua,
5151
https://www.lua.org/bugs.html#5.0-2
5252
53-
Synopsis: coroutine.close (co)
54-
Synopsis: coroutine.create (f)
55-
Synopsis: coroutine.isyieldable ([co])
56-
Synopsis: coroutine.resume (co [, val1, ···])
57-
Synopsis: coroutine.running ()
58-
Synopsis: coroutine.status (co)
59-
Synopsis: coroutine.wrap (f)
60-
Synopsis: coroutine.yield (···)
53+
Synopsis:
54+
55+
coroutine.close(co)
56+
coroutine.create(f)
57+
coroutine.isyieldable([co])
58+
coroutine.resume(co [, val1, ...])
59+
coroutine.running()
60+
coroutine.status(co)
61+
coroutine.wrap(f)
62+
coroutine.yield(...)
6163
]]
6264

6365
local luzer = require("luzer")
64-
local test_lib = require("lib")
6566

6667
local C = {}
6768

@@ -80,45 +81,31 @@ local CORO_STATE = {
8081
STATUS_YIELD,
8182
}
8283

83-
-- FIXME: Replace with `fdp:oneof()`.
84-
local function oneof(fdp, tbl)
85-
assert(type(tbl) == "table")
86-
assert(next(tbl) ~= nil)
87-
88-
local n = table.getn(tbl)
89-
local idx = fdp:consume_integer(1, n)
90-
return tbl[idx], idx
91-
end
92-
9384
-- Forward declaration.
9485
local coro_loop
9586

9687
local function random_coro(fdp)
97-
-- FIXME: Replace with `fdp:oneof()`.
98-
local coro, coro_n = oneof(fdp, C)
88+
local coro, coro_n = fdp:one_of(C)
9989
local coro_status = coroutine.status(coro)
10090
if coro_status == STATUS_DEAD then
10191
table.remove(C, coro_n)
10292
coro = coroutine.create(coro_loop)
10393
table.insert(C, coro)
10494
coroutine.resume(coro, 1)
10595
end
106-
-- FIXME: Replace with `fdp:oneof()`.
107-
return oneof(fdp, C)
96+
return fdp:one_of(C)
10897
end
10998

11099
local function coro_step(fdp)
111-
-- FIXME: Replace with `fdp:oneof()`.
112-
local state = oneof(fdp, CORO_STATE)
100+
local state = fdp:one_of(CORO_STATE)
113101
if state == STATUS_CREATE then
114102
local co = coroutine.create(coro_loop)
115103
table.insert(C, co)
116104
coroutine.resume(co, 1)
117105
return
118106
end
119107

120-
-- FIXME: Replace with `fdp:oneof()`.
121-
state = oneof(fdp, CORO_STATE)
108+
state = fdp:one_of(CORO_STATE)
122109
local coro = random_coro(fdp)
123110
local status = coroutine.status(coro)
124111
if status == STATUS_DEAD then

0 commit comments

Comments
 (0)