43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { expect, describe, test } from 'bun:test'
|
|
import { globals } from '#prelude'
|
|
|
|
describe('loading a file', () => {
|
|
test(`imports all a file's functions`, async () => {
|
|
expect(`
|
|
math = load ./src/prelude/tests/math.sh
|
|
math.double 4
|
|
`).toEvaluateTo(8, globals)
|
|
|
|
expect(`
|
|
math = load ./src/prelude/tests/math.sh
|
|
math.double (math.double 4)
|
|
`).toEvaluateTo(16, globals)
|
|
|
|
expect(`
|
|
math = load ./src/prelude/tests/math.sh
|
|
dbl = ref math.double
|
|
dbl (dbl 2)
|
|
`).toEvaluateTo(8, globals)
|
|
|
|
expect(`
|
|
math = load ./src/prelude/tests/math.sh
|
|
math.pi
|
|
`).toEvaluateTo(3.14, globals)
|
|
|
|
expect(`
|
|
math = load ./src/prelude/tests/math.sh
|
|
math | at 🥧
|
|
`).toEvaluateTo(3.14159265359, globals)
|
|
|
|
expect(`
|
|
math = load ./src/prelude/tests/math.sh
|
|
math.🥧
|
|
`).toEvaluateTo(3.14159265359, globals)
|
|
|
|
expect(`
|
|
math = load ./src/prelude/tests/math.sh
|
|
math.add1 5
|
|
`).toEvaluateTo(6, globals)
|
|
})
|
|
})
|