You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import { wrapFunc, trueValue, falseValue } from "cumlisp";
|
|
|
|
import { AssertionError } from "assert"
|
|
|
|
import { exit } from "process"
|
|
|
|
|
|
|
|
export default {
|
|
|
|
testSet: wrapFunc("testSet", -1, (args) => {
|
|
|
|
const setName = args.shift()
|
|
|
|
console.log(`Testing ${setName}...`)
|
|
|
|
let res = true
|
|
|
|
for (const i in args) {
|
|
|
|
args[i] = JSON.parse(args[i])
|
|
|
|
if (!args[i].res) {
|
|
|
|
console.log(` ${args[i].desc} failed!
|
|
|
|
- Expected: ${args[i].expected}
|
|
|
|
- Recieved: ${args[i].recieved}`)
|
|
|
|
res = false
|
|
|
|
} else {
|
|
|
|
console.log(` ${args[i].desc} succeeded!`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}),
|
|
|
|
assertTrue: wrapFunc("assertTrue", 2, (args) => {
|
|
|
|
let res
|
|
|
|
if (!args[1]) {
|
|
|
|
res = false
|
|
|
|
} else {
|
|
|
|
res = true
|
|
|
|
}
|
|
|
|
return JSON.stringify({
|
|
|
|
res: res,
|
|
|
|
desc: args[0],
|
|
|
|
expected: trueValue,
|
|
|
|
recieved: args[1]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|