From b805bbcae2ef9e08ef993b5c8b35a18dbb5a81d3 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Fri, 16 Jun 2017 18:01:22 +1000 Subject: tests/test-suite/inprogress/db.js: Escape escapes --- tests/test-suite/inprogress/db.js | 57 +++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/tests/test-suite/inprogress/db.js b/tests/test-suite/inprogress/db.js index 0fd250b..b6ac68b 100644 --- a/tests/test-suite/inprogress/db.js +++ b/tests/test-suite/inprogress/db.js @@ -1259,42 +1259,39 @@ test("[test-suite] db: testing for-iterator name", function (t) { test("[test-suite] db: testing traceback sizes", function (t) { let luaCode = ` - do - local function countlines (s) - return select(2, string.gsub(s, "\n", "")) - end + local function countlines (s) + return select(2, string.gsub(s, "\\n", "")) + end - local function deep (lvl, n) - if lvl == 0 then - return (debug.traceback("message", n)) - else - return (deep(lvl-1, n)) - end + local function deep (lvl, n) + if lvl == 0 then + return (debug.traceback("message", n)) + else + return (deep(lvl-1, n)) end + end - local function checkdeep (total, start) - local s = deep(total, start) - local rest = string.match(s, "^message\nstack traceback:\n(.*)$") - local cl = countlines(rest) - -- at most 10 lines in first part, 11 in second, plus '...' - assert(cl <= 10 + 11 + 1) - local brk = string.find(rest, "%.%.%.") - if brk then -- does message have '...'? - local rest1 = string.sub(rest, 1, brk) - local rest2 = string.sub(rest, brk, #rest) - assert(countlines(rest1) == 10 and countlines(rest2) == 11) - else - assert(cl == total - start + 2) - end + local function checkdeep (total, start) + local s = deep(total, start) + local rest = string.match(s, "^message\\nstack traceback:\\n(.*)$") + local cl = countlines(rest) + -- at most 10 lines in first part, 11 in second, plus '...' + assert(cl <= 10 + 11 + 1) + local brk = string.find(rest, "%.%.%.") + if brk then -- does message have '...'? + local rest1 = string.sub(rest, 1, brk) + local rest2 = string.sub(rest, brk, #rest) + assert(countlines(rest1) == 10 and countlines(rest2) == 11) + else + assert(cl == total - start + 2) end + end - for d = 1, 51, 10 do - for l = 1, d do - -- use coroutines to ensure complete control of the stack - coroutine.wrap(checkdeep)(d, l) - end + for d = 1, 51, 10 do + for l = 1, d do + -- use coroutines to ensure complete control of the stack + coroutine.wrap(checkdeep)(d, l) end - end `, L; -- cgit v1.2.3-70-g09d2