okay so uh it works completely differently now lol

master
Drake 2 years ago
parent f7eb854196
commit 98a92370c2

@ -10,9 +10,16 @@ test(vm)
//is it funny that we're testing the unit testing with the unit testing?
//
//yes
console.log(await run(`%(
/*console.log(await run(`%(
(set x "deez")
(assertTrue "Successful assertion to true" (equals 1 1))
(assertTrue "Failed assertion to true" (equals 1 0))
(assertTrue "Assertion with variables and strings" (equals (x) "deez"))
)`, vm))*/
console.log(await run(`%(
(set x "deez")
(testSet "Test set 1"
(assertTrue "Successful assertion to true" (equals 1 1))
(assertTrue "Failed assertion to true" (equals 1 0))
(assertTrue "Assertion with variables and strings" (equals (x) "deez")))
)`, vm))

@ -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]
})
})
}

Loading…
Cancel
Save