Allow test harness to expect panics
This commit is contained in:
parent
d12d485583
commit
8b47aab280
|
@ -6,13 +6,25 @@ const case_path = "./cases"
|
||||||
const files = await fs.readdir(case_path)
|
const files = await fs.readdir(case_path)
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const script = await fs.readFile(`${case_path}/${file}`, {encoding: "utf8"})
|
const source = await fs.readFile(`${case_path}/${file}`, {encoding: "utf8"})
|
||||||
const first_line = script.split("\n")[0]
|
const first_line = source.split("\n")[0]
|
||||||
const expected = first_line.split("EXPECT")[1].trim()
|
const expected = first_line.split("EXPECT")[1].trim()
|
||||||
const result = run(script).result
|
if (expected === "PANIC") expect_panic(file, source)
|
||||||
t.test(`testing ${file}: EXPECT ${expected}, GOT ${result}`,
|
else expect_result(file, source, expected)
|
||||||
t => {
|
}
|
||||||
t.equal(expected, result)
|
|
||||||
t.end()
|
function expect_panic(file, source) {
|
||||||
})
|
const result = run(source).errors[0]
|
||||||
|
t.test(`testing ${file}: EXPECT PANIC`, t => {
|
||||||
|
t.ok(result)
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function expect_result(file, source, expected) {
|
||||||
|
const result = run(source).result
|
||||||
|
t.test(`testing ${file}: EXPECT ${expected}, GOT ${result}`, t => {
|
||||||
|
t.equal(expected, result)
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user