|
|
|
@ -3,17 +3,35 @@ 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]) {
|
|
|
|
|
/*throw new AssertionError({
|
|
|
|
|
message: `"${args[0]}" failed!`,
|
|
|
|
|
actual: args[1],
|
|
|
|
|
expected: trueValue
|
|
|
|
|
})*/
|
|
|
|
|
console.log(`"${args[0]}" failed!
|
|
|
|
|
Expected: '${trueValue}'
|
|
|
|
|
Recieved: '${args[1]}'`)
|
|
|
|
|
res = false
|
|
|
|
|
} else {
|
|
|
|
|
res = true
|
|
|
|
|
}
|
|
|
|
|
return args[1]
|
|
|
|
|
return JSON.stringify({
|
|
|
|
|
res: res,
|
|
|
|
|
desc: args[0],
|
|
|
|
|
expected: trueValue,
|
|
|
|
|
recieved: args[1]
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|