pax_global_header00006660000000000000000000000064132451077270014522gustar00rootroot0000000000000052 comment=ea22f44e490430e40217f0792bf82eaeaec51903 coxpcall-1_17_0/000077500000000000000000000000001324510772700135575ustar00rootroot00000000000000coxpcall-1_17_0/Makefile000066400000000000000000000006671324510772700152300ustar00rootroot00000000000000# $Id: Makefile,v 1.3 2008/01/22 18:39:18 mascarenhas Exp $ config_file:=config DESTDIR ?= / ifneq '$(wildcard $(config_file))' '' include $(config_file) endif $(config_file): chmod +x configure install: $(config_file) mkdir -p $(DESTDIR)$(LUA_DIR) cp src/coxpcall.lua $(DESTDIR)$(LUA_DIR)/ install-doc: install mkdir -p $(DESTDIR)$(DOC_PREFIX)/doc cp -r doc/* $(DESTDIR)$(DOC_PREFIX)/doc echo "Go to $(DOC_PREFIX) for docs!" coxpcall-1_17_0/Makefile.win000066400000000000000000000004371324510772700160170ustar00rootroot00000000000000# $Id: Makefile.win,v 1.3 2008/01/23 03:01:31 mascarenhas Exp $ LUA_DIR=C:\lua5.1\lua install: IF NOT EXIST "$(LUA_DIR)" mkdir "$(LUA_DIR)" copy src\coxpcall.lua "$(LUA_DIR)\" install-rocks: install IF NOT EXIST "$(PREFIX)\doc" mkdir "$(PREFIX)\doc" xcopy /E doc "$(PREFIX)\doc\" coxpcall-1_17_0/README.md000066400000000000000000000013501324510772700150350ustar00rootroot00000000000000# Coxpcall Coxpcall encapsulates the protected calls with a coroutine based loop, so errors can be handled without the usual pcall/xpcall issues with coroutines for Lua 5.1. http://keplerproject.github.io/coxpcall/ Using Coxpcall usually consists in simply loading the module and then replacing Lua pcall and xpcall by copcall and coxpcall. Coxpcall is free software and uses the same license as Lua 5.1. Coxpcall can be downloaded from its GitHub page. You can also get Coxpcall using LuaRocks: luarocks install coxpcall Lua 5.2 was extended with the Coxpcall functionality and hence it is no longer required. The 5.2+ compatibility by coxpcall means that it maintains backward compatibility while using the built-in Lua implementation. coxpcall-1_17_0/configure000077500000000000000000000014161324510772700154700ustar00rootroot00000000000000#!/bin/bash if [ $1 == "--help" ]; then echo "Usage: configure lua51" echo "where lua51 is the name of your Lua executable" exit 0 fi echo "Trying to find where you installed Lua..." if [ $1 != "" ]; then lua=$1 else lua="lua51" fi lua_bin=`which $lua` lua_bin_dir=`dirname $lua_bin` lua_root=`dirname $lua_bin_dir` if [ $lua_root != "" ]; then echo "Lua is in $lua_root" echo "Writing config" lua_share=$lua_root/share/lua/5.1 lua_lib=$lua_root/lib/lua/5.1 bin_dir=$lua_root/bin echo "LUA_BIN= $lua_bin" > config echo "LUA_DIR= $lua_share" >> config echo "BIN_DIR= $bin_dir" >> config echo "LUA_LIBDIR= $lua_lib" >> config echo "Now run 'make && sudo make install'" else echo "Lua not found, please install Lua 5.1 (and put in your PATH)" fi coxpcall-1_17_0/doc/000077500000000000000000000000001324510772700143245ustar00rootroot00000000000000coxpcall-1_17_0/doc/coxpcall.png000066400000000000000000000273701324510772700166500ustar00rootroot00000000000000PNG  IHDRL\ pHYsHHFk>.bIDATx=ixTE-d'@HHB@.H7F?y (˧μϙ3OEEQDdUdQB $@! 餻UG/7%wNݺU:u:cy;{ t<*B=n0TԻw 8G}w 899 rssWBM6(=z}NNN~~>h4CKāAgЙP>(F1!!… `6tRPPhj(B)?vc2E_Ŝ!zcRRRAAfk׮FU`' 'f#!BG}VF.˔Rߌ1P&_wSс1ed2@||; zuYf0Tqڵ늢8Q͛g4).]z-.8 GR2%B6\Zjihp fQ$!HBuL:tرcMMM0{~uڵ{.\HHH$<66VB)5 c@Q;/^vb1b7IKcLpCo.lݚ]ZV I bTTȑя?2uj_( Kw*˫GW_]xqƌ{޽{Ν;1 999н{w|5N4_EYhhcvB-SYY9|X>`֮z㍃ׯW  f;+yf~+VL1#QQ(h{ʰAUBeeegNMM IMM-**r $&&VWW!""">?&|U7[T3""{޽{}}M?oڴfJQ(ƨiڴMQZZCH!FV1al-9s…"E[BǮ1v… 6-111$$DÇ@zzѣGCCC?m2.]{1ރ*hYL)odC Z\U{PhT|err(TQ'Ea cƺO>9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SiӦ{,<<@כ6mxkJo6M[YjeH- LEy/?/ExgweO4ܹsRHo~3jsn1b\_82 Կ2!8yr򫯎iHwh)}.yOs6hР{765($wܵNGDDaukG)mP9UWWBYt*22pÆ_"qAe f̫{JX,jyN1ֵk{.!!K%?":fL'< `=hМȘ}͚'Në/zO+We  FZ^,+sP&^|߄ R[o=``~ǧ߻w$I)))f~}L_|qX;Ȣf˲קnsy r ~G}_ϛSUL~nB$?ϐFyI绖 !Lr07',A_80%%E-y'zO<ϓYJY&kɒÄw?Ø0&1\ҥ|b4jAAAHHHHHn޽ޛmVۨC'KxݻեAQUJ;v99yuũc<{9rd/߯(vBH5y BEq,_>1#cQ||7w#+**Mr3;TACCڵA}X,ܹ  wfc`QC̘-1+Wŋ/oT|@ʕoyNꃂ_{me#yK>k2`7lp^xWoչs5-.4,/ox督WXtN3mvs2JE(5~I?n6m:s=j)'.\#g4wٖZVZ6J6b$Qs&(]p%Ch!$Iƍᄒ}\Uڙ(((XjUJJٳnZ,X;/_G9wO{J]m4k޼{|?%^{;r\k*k}GsqYO2G_ݛgO^zzQqq-G(Eu~ 5*fԾSnNnz-CٟN9/𬭭裏|xRRҶmտ3<_ss@Jڶmf[t)hD_}V@; 2@QQQ<@߾};.б+@;zAkB(##ԩS<@Ϟ=]̅>y-yΚjQ=zʕ+ljrU6/((ػwիW{1lذÇzR";>sͦl6B]u(`"==ҥKO?KHUixs&- Z!TWWw嬬LdY&tAAAvvvRRRdddPP>htRo=rH```޽SSS/Nj{'Кl .1իWϜ9Eq̙ PRSSXEw]V嚚ݻ5JiRRR|||||<5ȺE"4 Coxpcall - Coroutine Safe xpcall and pcall
Coxpcall
Coroutine-safe xpcall and pcall versions

Overview

Coxpcall encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual pcall/xpcall issues with coroutines.

Using Coxpcall usually consists in simply loading the module and then replacing Lua pcall, xpcall and coroutine.running by copcall, coxpcall, and running.

Coxpcall is free software and uses the same license as Lua 5.1 and 5.2.

Status

It supports Lua 5.1, 5.2 and 5.3. Lua 5.2 was extended with the Coxpcall functionality and hence coxpcall is no longer required. The 5.2+ compatibility by coxpcall means that it maintains backward compatibility while using the built-in implementation.

Download

You can get Coxpcall using LuaRocks:

luarocks install coxpcall

See also its GitHub page.

Reference

Coxpcall module offers three functions that reproduce the behaviour of pcall, xpcall, and coroutine.running:

local coxpcall = require "coxpcall"
coxpcall.xpcall(f, err)
Offers the same functionality as Lua xpcall(f, err), but calls the error handler after the error unwinds the stack, so that it's impossible to gather more information about the error. To compensate, if the error is a string, stack trace is appended to it. Also set as global coxpcall.
coxpcall.pcall(f, ...)
Offers the same functionality as Lua pcall(f, ...). Also set as global copcall.
coxpcall.running([coro])
Because coxpcall and copcall run the function to protect inside a new coroutine, coroutine.running() will return an unexpected coroutine when used inside the protected function. If the coroutine coro was created by the coxpcall module, then running(coro) will return the original coroutine that created it. If coro is not provided, it will default to the currently running coroutine.

Credits

Coxpcall was designed and implemented by Roberto Ierusalimschy and André Carregal with the colaboration of Thomas Harning Jr., Ignacio Burgueño, Gary NG and Fábio Mascarenhas as part of the Kepler Project which holds its copyright.

coxpcall-1_17_0/doc/license.html000066400000000000000000000100101324510772700166240ustar00rootroot00000000000000 Coxpcall License
Coxpcall
Coroutine-safe xpcall and pcall versions

Coxpcall License

Coxpcall is free software: it can be used for both academic and commercial purposes at absolutely no cost. There are no royalties or GNU-like "copyleft" restrictions. Coxpcall qualifies as Open Source software. Its licenses are compatible with GPL. Coxpcall is not in the public domain and its authors keep its copyright. The legal details are below.

The spirit of the license is that you are free to use Coxpcall for any purpose at no cost without having to ask us. The only requirement is that if you do use Coxpcall, then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.

Coxpcall was designed and implemented by Roberto Ierusalimschy and André Carregal. The implementation is not derived from licensed software.


Copyright © 2005 Kepler Project.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Valid XHTML 1.0!

$Id: license.html,v 1.1 2008/01/17 20:41:05 carregal Exp $

coxpcall-1_17_0/rockspec/000077500000000000000000000000001324510772700153705ustar00rootroot00000000000000coxpcall-1_17_0/rockspec/coxpcall-1.11.0-1.rockspec000066400000000000000000000013041324510772700216000ustar00rootroot00000000000000package = "Coxpcall" version = "1.11.0-1" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } source = { url = "http://luaforge.net/frs/download.php/3047/coxpcall-1.11.0.tar.gz", } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } coxpcall-1_17_0/rockspec/coxpcall-1.12.0-1.rockspec000066400000000000000000000013041324510772700216010ustar00rootroot00000000000000package = "Coxpcall" version = "1.12.0-1" source = { url = "http://luaforge.net/frs/download.php/3351/coxpcall-1.12.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } coxpcall-1_17_0/rockspec/coxpcall-1.12.0rc1-1.rockspec000066400000000000000000000012751324510772700222160ustar00rootroot00000000000000package = "Coxpcall" version = "1.12.0rc1-1" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } source = { url = "http://coxpcall.luaforge.net/coxpcall-1.12.0rc1.tar.gz", } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } coxpcall-1_17_0/rockspec/coxpcall-1.13.0-1.rockspec000066400000000000000000000013041324510772700216020ustar00rootroot00000000000000package = "Coxpcall" version = "1.13.0-1" source = { url = "http://luaforge.net/frs/download.php/3406/coxpcall-1.13.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } coxpcall-1_17_0/rockspec/coxpcall-1.13.0-2.rockspec000066400000000000000000000011101324510772700215760ustar00rootroot00000000000000package = "Coxpcall" version = "1.13.0-2" source = { url = "http://luaforge.net/frs/download.php/3406/coxpcall-1.13.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } build = { type = "module", modules = { coxpcall = "src/coxpcall.lua" } } coxpcall-1_17_0/rockspec/coxpcall-1.14.0-1.rockspec000066400000000000000000000011021324510772700215770ustar00rootroot00000000000000package = "Coxpcall" version = "1.14.0-1" source = { url = "http://www.keplerproject.org/files/coxpcall-1.14.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } build = { type = "builtin", modules = { coxpcall = "src/coxpcall.lua" } } coxpcall-1_17_0/rockspec/coxpcall-1.14.0-2.rockspec000066400000000000000000000011161324510772700216050ustar00rootroot00000000000000package = "Coxpcall" version = "1.14.0-1" source = { url = "http://www.keplerproject.org/files/coxpcall-1.14.0.tar.gz", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://keplerproject.github.com/coxpcall" } dependencies = { } build = { type = "builtin", modules = { coxpcall = "src/coxpcall.lua" } } coxpcall-1_17_0/rockspec/coxpcall-1.15.0-1.rockspec000066400000000000000000000011171324510772700216060ustar00rootroot00000000000000package = "Coxpcall" version = "1.15.0-1" source = { url = "git://github.com/keplerproject/coxpcall", tag = "v1_15_0", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://keplerproject.github.com/coxpcall" } dependencies = { } build = { type = "builtin", modules = { coxpcall = "src/coxpcall.lua" } } coxpcall-1_17_0/rockspec/coxpcall-1.16.0-1.rockspec000066400000000000000000000011171324510772700216070ustar00rootroot00000000000000package = "Coxpcall" version = "1.16.0-1" source = { url = "git://github.com/keplerproject/coxpcall", tag = "v1_16_0", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be handled without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://keplerproject.github.io/coxpcall" } dependencies = { } build = { type = "builtin", modules = { coxpcall = "src/coxpcall.lua" } } coxpcall-1_17_0/rockspec/coxpcall-1.17.0-1.rockspec000066400000000000000000000011171324510772700216100ustar00rootroot00000000000000package = "Coxpcall" version = "1.17.0-1" source = { url = "git://github.com/keplerproject/coxpcall", tag = "v1_17_0", } description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be handled without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://keplerproject.github.io/coxpcall" } dependencies = { } build = { type = "builtin", modules = { coxpcall = "src/coxpcall.lua" } } coxpcall-1_17_0/rockspec/coxpcall-cvs-1.rockspec000066400000000000000000000013201324510772700216530ustar00rootroot00000000000000package = "Coxpcall" version = "cvs-1" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } source = { url = "cvs://:pserver:anonymous:@cvs.luaforge.net:/cvsroot/coxpcall", cvs_tag = "HEAD" } build = { type = "make", build_pass = false, install_target = "install-rocks", install_variables = { PREFIX = "$(PREFIX)", LUA_DIR = "$(LUADIR)", BIN_DIR = "$(BINDIR)" } } coxpcall-1_17_0/rockspec/coxpcall-cvs-2.rockspec000066400000000000000000000010571324510772700216630ustar00rootroot00000000000000package = "Coxpcall" version = "cvs-2" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://coxpcall.luaforge.net" } dependencies = { } source = { url = "git://github.com/keplerproject/coxpcall.git" } build = { type = "module", modules = { coxpcall = "src/coxpcall.lua" } } coxpcall-1_17_0/rockspec/coxpcall-scm-1.rockspec000066400000000000000000000010741324510772700216500ustar00rootroot00000000000000package = "Coxpcall" version = "scm-1" description = { summary = "Coroutine safe xpcall and pcall", detailed = [[ Encapsulates the protected calls with a coroutine based loop, so errors can be handled without the usual Lua 5.x pcall/xpcall issues with coroutines yielding inside the call to pcall or xpcall. ]], license = "MIT/X11", homepage = "http://keplerproject.github.io/coxpcall" } dependencies = { } source = { url = "git://github.com/keplerproject/coxpcall.git" } build = { type = "builtin", modules = { coxpcall = "src/coxpcall.lua" } } coxpcall-1_17_0/src/000077500000000000000000000000001324510772700143465ustar00rootroot00000000000000coxpcall-1_17_0/src/coxpcall.lua000066400000000000000000000067161324510772700166700ustar00rootroot00000000000000------------------------------------------------------------------------------- -- Coroutine safe xpcall and pcall versions -- -- Encapsulates the protected calls with a coroutine based loop, so errors can -- be dealed without the usual Lua 5.x pcall/xpcall issues with coroutines -- yielding inside the call to pcall or xpcall. -- -- Authors: Roberto Ierusalimschy and Andre Carregal -- Contributors: Thomas Harning Jr., Ignacio Burgueño, Fabio Mascarenhas -- -- Copyright 2005 - Kepler Project -- -- $Id: coxpcall.lua,v 1.13 2008/05/19 19:20:02 mascarenhas Exp $ ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Checks if (x)pcall function is coroutine safe ------------------------------------------------------------------------------- local function isCoroutineSafe(func) local co = coroutine.create(function() return func(coroutine.yield, function() end) end) coroutine.resume(co) return coroutine.resume(co) end -- No need to do anything if pcall and xpcall are already safe. if isCoroutineSafe(pcall) and isCoroutineSafe(xpcall) then copcall = pcall coxpcall = xpcall return { pcall = pcall, xpcall = xpcall, running = coroutine.running } end ------------------------------------------------------------------------------- -- Implements xpcall with coroutines ------------------------------------------------------------------------------- local performResume, handleReturnValue local oldpcall, oldxpcall = pcall, xpcall local pack = table.pack or function(...) return {n = select("#", ...), ...} end local unpack = table.unpack or unpack local running = coroutine.running local coromap = setmetatable({}, { __mode = "k" }) function handleReturnValue(err, co, status, ...) if not status then return false, err(debug.traceback(co, (...)), ...) end if coroutine.status(co) == 'suspended' then return performResume(err, co, coroutine.yield(...)) else return true, ... end end function performResume(err, co, ...) return handleReturnValue(err, co, coroutine.resume(co, ...)) end local function id(trace, ...) return trace end function coxpcall(f, err, ...) local current = running() if not current then if err == id then return oldpcall(f, ...) else if select("#", ...) > 0 then local oldf, params = f, pack(...) f = function() return oldf(unpack(params, 1, params.n)) end end return oldxpcall(f, err) end else local res, co = oldpcall(coroutine.create, f) if not res then local newf = function(...) return f(...) end co = coroutine.create(newf) end coromap[co] = current return performResume(err, co, ...) end end local function corunning(coro) if coro ~= nil then assert(type(coro)=="thread", "Bad argument; expected thread, got: "..type(coro)) else coro = running() end while coromap[coro] do coro = coromap[coro] end if coro == "mainthread" then return nil end return coro end ------------------------------------------------------------------------------- -- Implements pcall with coroutines ------------------------------------------------------------------------------- function copcall(f, ...) return coxpcall(f, id, ...) end return { pcall = copcall, xpcall = coxpcall, running = corunning } coxpcall-1_17_0/tests/000077500000000000000000000000001324510772700147215ustar00rootroot00000000000000coxpcall-1_17_0/tests/test.lua000066400000000000000000000127471324510772700164160ustar00rootroot00000000000000#!/usr/bin/env lua package.path = "../src/?.lua;./src/?.lua" local M = require("coxpcall") local count, errortable = 0, {} -- test helper functions local function assert(ok, ...) if not ok then local msg = ... error(msg == nil and "assertion failed" or msg, 0) else return ok, ... end end local function error_is(f, xmsg) local ok, msg = pcall(f) assert(ok == false, "function did not raise an error") assert(msg == xmsg, "error message not as expected:\n\t"..tostring(msg)) count = count + 1 end local function error_matches(f, pat) local ok, msg = pcall(f) assert(ok == false, "function did not raise an error") assert(type(msg) == "string", "error message is not a string:\n\t"..type(msg)) assert(msg:match(pat), "error message didn't match pattern:\n\t"..pat.."\n\t"..msg) count = count + 1 end local function succeeds(f) local ok, msg = pcall(f) assert(ok, "function raised an error\n\t:"..tostring(msg)) count = count + 1 end local function succeeds_with(f, xrets) local function packrets(ok, ...) return ok, { n=select("#", ...), ... } end local ok, rets = packrets(pcall(f)) assert(ok, "function raised an error\n\t:"..tostring(rets[1])) assert(rets.n == xrets.n or #xrets, "unexpected number of return values: "..rets.n.. " (expected: "..(xrets.n or #xrets)..")") for i = 1, rets.n do assert(rets[i] == xrets[i], "unexpected return value no. "..i.." (".. tostring(rets[i])..", expected: "..tostring(xrets[i])..")") end count = count + 1 end local function traceback() return "XXX" end -- the tests: -- co(x)pcall from main thread succeeds_with(function() return M.pcall(function(...) return ... end, 1, 2, 3) end, { true, 1, 2, 3 }) succeeds_with(function() return M.xpcall(function() return 1, 2, 3 end, debug.traceback) end, { true, 1, 2, 3 }) error_matches(function() return assert(M.pcall(function(...) error("ARGH", 0) end, 1, 2, 3)) end, "ARGH") error_is(function() return assert(M.pcall(function(...) error(errortable, 0) end, 1, 2, 3)) end, errortable) error_matches(function() return assert(M.xpcall(function() error("ARGH", 0) end, debug.traceback)) end, "ARGH") error_is(function() return assert(M.xpcall(function() error(errortable, 0) end, debug.traceback)) end, errortable) error_matches(function() return assert(M.xpcall(function() error("ARGH", 0) end, traceback)) end, "XXX") error_matches(function() return assert(M.pcall(rawset)) end, "bad argument") -- co(x)pcall from within coroutine (without yielding) succeeds_with(coroutine.wrap(function() return M.pcall(function(...) return ... end, 1, 2, 3) end), { true, 1, 2, 3 }) succeeds_with(coroutine.wrap(function() return M.xpcall(function() return 1, 2, 3 end, debug.traceback) end), { true, 1, 2, 3 }) error_matches(coroutine.wrap(function() return assert(M.pcall(function(...) error("ARGH", 0) end, 1, 2, 3)) end), "ARGH") error_is(coroutine.wrap(function() return assert(M.pcall(function(...) error(errortable, 0) end, 1, 2, 3)) end), errortable) error_matches(coroutine.wrap(function() return assert(M.xpcall(function() error("ARGH", 0) end, debug.traceback)) end), "ARGH") error_is(coroutine.wrap(function() return assert(M.xpcall(function() error(errortable, 0) end, debug.traceback)) end), errortable) error_matches(coroutine.wrap(function() return assert(M.xpcall(function() error("ARGH", 0) end, traceback)) end), "XXX") error_matches(coroutine.wrap(function() return assert(M.pcall(rawset)) end), "bad argument") -- co(x)pcall from within coroutine (with yielding) succeeds_with(function() local f = coroutine.wrap(function(...) return M.pcall(function(...) coroutine.yield() return ... end, ...) end) f(1, 2, 3) return f() end, { true, 1, 2, 3 }) succeeds_with(function() local f = coroutine.wrap(function() return M.xpcall(function() coroutine.yield() return 1, 2, 3 end, debug.traceback) end) f() return f() end, { true, 1, 2, 3 }) error_matches(function() local f = coroutine.wrap(function(...) return assert(M.pcall(function(...) coroutine.yield() error("ARGH", 0) end, ...)) end) f( 1, 2, 3) return f() end, "ARGH") error_is(function() local f = coroutine.wrap(function(...) return assert(M.pcall(function(...) coroutine.yield() error(errortable, 0) end, ...)) end) f( 1, 2, 3) return f() end, errortable) error_matches(function() local f = coroutine.wrap(function() return assert(M.xpcall(function() coroutine.yield() error("ARGH", 0) end, debug.traceback)) end) f() return f() end, "ARGH") error_is(function() local f = coroutine.wrap(function() return assert(M.xpcall(function() coroutine.yield() error(errortable, 0) end, debug.traceback)) end) f() return f() end, errortable) error_matches(function() local f = coroutine.wrap(function() return assert(M.xpcall(function() coroutine.yield() error("ARGH", 0) end, traceback)) end) f() return f() end, "XXX") -- running succeeds(function() local co = coroutine.create(function() local _,c2 = M.pcall(M.running) local _,c3 = M.xpcall(M.running, debug.traceback) return c2, c3 end) local _, r1, r2 = assert(coroutine.resume(co)) assert(r1 == co, "running returned wrong thread") assert(r2 == co, "running returned wrong thread") end) print("OK", count)