diff options
Diffstat (limited to 'testes')
-rw-r--r-- | testes/db.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/testes/db.lua b/testes/db.lua index d64952d9..11dfd26c 100644 --- a/testes/db.lua +++ b/testes/db.lua | |||
@@ -195,6 +195,49 @@ do -- testing line info/trace with large gaps in source | |||
195 | end | 195 | end |
196 | end | 196 | end |
197 | 197 | ||
198 | |||
199 | do -- testing active lines | ||
200 | local function checkactivelines (f, lines) | ||
201 | local t = debug.getinfo(f, "SL") | ||
202 | for _, l in pairs(lines) do | ||
203 | l = l + t.linedefined | ||
204 | assert(t.activelines[l]) | ||
205 | t.activelines[l] = undef | ||
206 | end | ||
207 | assert(next(t.activelines) == nil) -- no extra lines | ||
208 | end | ||
209 | |||
210 | checkactivelines(function (...) -- vararg function | ||
211 | -- 1st line is empty | ||
212 | -- 2nd line is empty | ||
213 | -- 3th line is empty | ||
214 | local a = 20 | ||
215 | -- 5th line is empty | ||
216 | local b = 30 | ||
217 | -- 7th line is empty | ||
218 | end, {4, 6, 8}) | ||
219 | |||
220 | checkactivelines(function (a) | ||
221 | -- 1st line is empty | ||
222 | -- 2nd line is empty | ||
223 | local a = 20 | ||
224 | local b = 30 | ||
225 | -- 5th line is empty | ||
226 | end, {3, 4, 6}) | ||
227 | |||
228 | checkactivelines(function (...) end, {0}) | ||
229 | |||
230 | checkactivelines(function (a, b) | ||
231 | end, {1}) | ||
232 | |||
233 | for _, n in pairs{0, 1, 2, 10, 50, 100, 1000, 10000} do | ||
234 | checkactivelines( | ||
235 | load(string.format("%s return 1", string.rep("\n", n))), | ||
236 | {n + 1}) | ||
237 | end | ||
238 | |||
239 | end | ||
240 | |||
198 | print'+' | 241 | print'+' |
199 | 242 | ||
200 | -- invalid levels in [gs]etlocal | 243 | -- invalid levels in [gs]etlocal |