aboutsummaryrefslogtreecommitdiff
path: root/testes/errors.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/errors.lua')
-rw-r--r--testes/errors.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/testes/errors.lua b/testes/errors.lua
index 80d91a92..0925fe58 100644
--- a/testes/errors.lua
+++ b/testes/errors.lua
@@ -117,6 +117,31 @@ else
117 return 1 117 return 1
118 ]] 118 ]]
119 assert(string.find(res, "xuxu.-main chunk")) 119 assert(string.find(res, "xuxu.-main chunk"))
120
121 do -- tests for error messages about extra arguments from __call
122 local function createobj (n)
123 -- function that raises an error on its n-th argument
124 local code = string.format("argerror %d 'msg'", n)
125 local func = T.makeCfunc(code)
126 -- create a chain of 2 __call objects
127 local M = setmetatable({}, {__call = func})
128 M = setmetatable({}, {__call = M})
129 -- put it as a method for a new object
130 return {foo = M}
131 end
132
133 _G.a = createobj(1) -- error in first (extra) argument
134 checkmessage("a:foo()", "bad extra argument #1")
135
136 _G.a = createobj(2) -- error in second (extra) argument
137 checkmessage("a:foo()", "bad extra argument #2")
138
139 _G.a = createobj(3) -- error in self (after two extra arguments)
140 checkmessage("a:foo()", "bad self")
141
142 _G.a = createobj(4) -- error in first regular argument (after self)
143 checkmessage("a:foo()", "bad argument #1")
144 end
120end 145end
121 146
122 147