Compare commits
2 Commits
fe6f54b402
...
012b8c8cf1
| Author | SHA1 | Date | |
|---|---|---|---|
| 012b8c8cf1 | |||
| 4c3f7a8bfc |
|
|
@ -42,6 +42,7 @@ export const globals = {
|
|||
'var?': function (this: VM, v: string) {
|
||||
return typeof v !== 'string' || this.scope.has(v)
|
||||
},
|
||||
ref: (fn: Function) => fn,
|
||||
|
||||
// env
|
||||
args: Bun.argv.slice(1),
|
||||
|
|
|
|||
|
|
@ -91,3 +91,15 @@ describe('environment', () => {
|
|||
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