34 lines
766 B
TypeScript
34 lines
766 B
TypeScript
import { expect, describe, test } from 'bun:test'
|
|
|
|
import '../shrimp.grammar' // Importing this so changes cause it to retest!
|
|
|
|
describe('import', () => {
|
|
test('parses single import', () => {
|
|
expect(`import str`).toMatchTree(`
|
|
Import
|
|
keyword import
|
|
Identifier str
|
|
`)
|
|
})
|
|
|
|
test('parses multiple imports', () => {
|
|
expect(`import str math list`).toMatchTree(`
|
|
Import
|
|
keyword import
|
|
Identifier str
|
|
Identifier math
|
|
Identifier list
|
|
`)
|
|
})
|
|
|
|
test('parses named args', () => {
|
|
expect(`import str only=ends-with?`).toMatchTree(`
|
|
Import
|
|
keyword import
|
|
Identifier str
|
|
NamedArg
|
|
NamedArgPrefix only=
|
|
Identifier ends-with?
|
|
`)
|
|
})
|
|
}) |