56 lines
1.3 KiB
TypeScript
56 lines
1.3 KiB
TypeScript
import { expect, describe, test } from 'bun:test'
|
|
|
|
describe('single line function blocks', () => {
|
|
test('work with no args', () => {
|
|
expect(`trap = do x: x end; trap: true end`).toEvaluateTo(true)
|
|
})
|
|
|
|
test('work with one arg', () => {
|
|
expect(`trap = do x y: [ x (y) ] end; trap EXIT: true end`).toEvaluateTo(['EXIT', true])
|
|
})
|
|
|
|
test('work with named args', () => {
|
|
expect(`attach = do signal fn: [ signal (fn) ] end; attach signal='exit': true end`).toEvaluateTo(['exit', true])
|
|
})
|
|
|
|
|
|
test('work with dot-get', () => {
|
|
expect(`signals = [trap=do x y: [x (y)] end]; signals.trap 'EXIT': true end`).toEvaluateTo(['EXIT', true])
|
|
})
|
|
})
|
|
|
|
describe('multi line function blocks', () => {
|
|
test('work with no args', () => {
|
|
expect(`
|
|
trap = do x: x end
|
|
trap:
|
|
true
|
|
end`).toEvaluateTo(true)
|
|
})
|
|
|
|
test('work with one arg', () => {
|
|
expect(`
|
|
trap = do x y: [ x (y) ] end
|
|
trap EXIT:
|
|
true
|
|
end`).toEvaluateTo(['EXIT', true])
|
|
})
|
|
|
|
test('work with named args', () => {
|
|
expect(`
|
|
attach = do signal fn: [ signal (fn) ] end
|
|
attach signal='exit':
|
|
true
|
|
end`).toEvaluateTo(['exit', true])
|
|
})
|
|
|
|
|
|
test('work with dot-get', () => {
|
|
expect(`
|
|
signals = [trap=do x y: [x (y)] end]
|
|
signals.trap 'EXIT':
|
|
true
|
|
end`).toEvaluateTo(['EXIT', true])
|
|
})
|
|
})
|