@@ -386,17 +386,18 @@ local function batch_compare(batch, category, expected, got)
386
386
for i = 1 , # expected do
387
387
local e = expected [i ] or {}
388
388
local g = got [i ] or {}
389
+ local at = " [" .. (e .line and (" \" " .. e .line .. " \" " ) or i ) .. " ]"
389
390
if e .y then
390
- batch :add (assert .same , e .y , g .y , " [ " .. i .. " ] Expected same y location:" )
391
+ batch :add (assert .same , e .y , g .y , at .. " Expected same y location:" )
391
392
end
392
393
if e .x then
393
- batch :add (assert .same , e .x , g .x , " [ " .. i .. " ] Expected same x location:" )
394
+ batch :add (assert .same , e .x , g .x , at .. " Expected same x location:" )
394
395
end
395
396
if e .msg then
396
- batch :add (assert .match , e .msg , g .msg or " " , 1 , true , " [ " .. i .. " ] Expected messages to match:" )
397
+ batch :add (assert .match , e .msg , g .msg or " " , 1 , true , at .. " Expected messages to match:" )
397
398
end
398
399
if e .filename then
399
- batch :add (assert .match , e .filename , g .filename or " " , 1 , true , " [ " .. i .. " ] Expected filenames to match:" )
400
+ batch :add (assert .match , e .filename , g .filename or " " , 1 , true , at .. " Expected filenames to match:" )
400
401
end
401
402
end
402
403
if # got > # expected then
@@ -634,4 +635,21 @@ function util.run_lax_check(...)
634
635
return util .lax_check (... )()
635
636
end
636
637
638
+ function util .check_lines (prelude , testcases )
639
+ local code = prelude
640
+ local errs = {}
641
+ local y = 0
642
+ for _ in prelude :gmatch (" \n " ) do
643
+ y = y + 1
644
+ end
645
+ for _ , testcase in ipairs (testcases ) do
646
+ code = code .. testcase .line .. " \n "
647
+ y = y + 1
648
+ if testcase .err then
649
+ table.insert (errs , { y = y , line = testcase .line , msg = testcase .err })
650
+ end
651
+ end
652
+ return util .check_type_error (code , errs )
653
+ end
654
+
637
655
return util
0 commit comments