Init
commit
f7eb854196
@ -0,0 +1 @@
|
||||
node_modules
|
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "cumlisp",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cumlisp": "^1.3.1"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
import { wrapFunc, trueValue, falseValue } from "cumlisp"
|
||||
|
||||
export default {
|
||||
equals: wrapFunc("equals", 2, (args) => {
|
||||
if (args[0] === args[1]) return trueValue
|
||||
return falseValue
|
||||
}),
|
||||
inequals: wrapFunc("inequals", 2, (args) => {
|
||||
if (args[0] === args[1]) return falseValue
|
||||
return trueValue
|
||||
}),
|
||||
truthy: wrapFunc("truthy", 1, (args) => {
|
||||
if (args[0] === trueValue) return trueValue
|
||||
return falseValue
|
||||
})
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
import equalities from "./cases/equality/index.js"
|
||||
import test from "./testFunc.js"
|
||||
|
||||
export default function(vm) {
|
||||
vm.install(test)
|
||||
vm.install(equalities)
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
import { VM, run, libBasic } from "cumlisp"
|
||||
|
||||
import test from "./index.js"
|
||||
|
||||
const vm = new VM()
|
||||
|
||||
libBasic.installBasic(vm)
|
||||
test(vm)
|
||||
|
||||
//is it funny that we're testing the unit testing with the unit testing?
|
||||
//
|
||||
//yes
|
||||
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))
|
@ -0,0 +1,19 @@
|
||||
import { wrapFunc, trueValue, falseValue } from "cumlisp";
|
||||
import { AssertionError } from "assert"
|
||||
import { exit } from "process"
|
||||
|
||||
export default {
|
||||
assertTrue: wrapFunc("assertTrue", 2, (args) => {
|
||||
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]}'`)
|
||||
}
|
||||
return args[1]
|
||||
})
|
||||
}
|
Loading…
Reference in new issue