use -> load

This commit is contained in:
Chris Wanstrath 2025-10-28 22:23:49 -07:00
parent bf1196bf96
commit b738e6cfd1
2 changed files with 8 additions and 8 deletions

View File

@ -78,7 +78,7 @@ export const globalFunctions = {
}, },
// modules // modules
use: async function (this: VM, path: string): Promise<Record<string, Value>> { load: async function (this: VM, path: string): Promise<Record<string, Value>> {
const scope = this.scope const scope = this.scope
const pc = this.pc const pc = this.pc

View File

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