add ref for grabbing a function
This commit is contained in:
parent
fe6f54b402
commit
4c3f7a8bfc
|
|
@ -42,6 +42,7 @@ export const globals = {
|
||||||
'var?': function (this: VM, v: string) {
|
'var?': function (this: VM, v: string) {
|
||||||
return typeof v !== 'string' || this.scope.has(v)
|
return typeof v !== 'string' || this.scope.has(v)
|
||||||
},
|
},
|
||||||
|
ref: (fn: Function) => fn,
|
||||||
|
|
||||||
// env
|
// env
|
||||||
args: Bun.argv.slice(1),
|
args: Bun.argv.slice(1),
|
||||||
|
|
|
||||||
|
|
@ -91,3 +91,15 @@ describe('environment', () => {
|
||||||
await expect(`list.first args | str.ends-with? 'shrimp.test.ts'`).toEvaluateTo(true)
|
await expect(`list.first args | str.ends-with? 'shrimp.test.ts'`).toEvaluateTo(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('ref', () => {
|
||||||
|
expect(`rnd = do x: true end; rnd | type`).toEvaluateTo('boolean')
|
||||||
|
expect(`rnd = do x: true end; ref rnd | type`).toEvaluateTo('function')
|
||||||
|
|
||||||
|
expect(`math.random | type`).toEvaluateTo('number')
|
||||||
|
expect(`ref math.random | type`).toEvaluateTo('native')
|
||||||
|
|
||||||
|
expect(`rnd = math.random; rnd | type`).toEvaluateTo('number')
|
||||||
|
expect(`rnd = ref math.random; rnd | type`).toEvaluateTo('number')
|
||||||
|
expect(`rnd = ref math.random; ref rnd | type`).toEvaluateTo('native')
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user