shrimp/src/prelude/tests/load.ts

43 lines
990 B
TypeScript

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