File: 59-catch-special-only.lua

package info (click to toggle)
lua-cqueues 20161214-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,672 kB
  • ctags: 3,228
  • sloc: ansic: 20,232; sh: 2,959; makefile: 24
file content (43 lines) | stat: -rwxr-xr-x 732 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
_=[[
	. "${0%%/*}/regress.sh"
	exec runlua "$0" "$@"
]]

require"regress".export".*"

local cq = cqueues.new()

local MAXSTACK = 1000000 + 10

local co = coroutine.create(function(...)
	cq:wrap(function (...)
		for i=1,MAXSTACK do
			if 0 == i % math.floor(MAXSTACK / 100) then
				info("%d", i)
			end
			cqueues.poll(0)
			local n = coroutine.yield(i)
			check(n == i + 1)
		end
	end, ...)

	local ok, why, errno, thr = cq:loop()

	if not ok then
		io.stderr:write(debug.traceback(thr))
		check(false)
	end
	
	return "done"
end)

for i=1,MAXSTACK do
	local ok, j = coroutine.resume(co, i)
	check(i == j)
end

check("done" == select(2, coroutine.resume(co, MAXSTACK + 1)))
check(coroutine.status(co) == "dead")

say("OK")