1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { Expr, parse } from '../src/parse-expr'
describe('parser', () => {
it('should parse function call', () => {
expect(parse('hello()')).toEqual([Expr.Call({ name: 'hello', args: [] })])
expect(parse('hello ( wow , foo ) ')).toEqual([
Expr.Call({
name: 'hello',
args: [Expr.Identifier('wow'), Expr.Identifier('foo')],
}),
])
expect(parse('hello(wow,foo)')).toEqual([
Expr.Call({
name: 'hello',
args: [Expr.Identifier('wow'), Expr.Identifier('foo')],
}),
])
expect(parse('hello(wow,foo, coolio)')).toEqual([
Expr.Call({
name: 'hello',
args: [
Expr.Identifier('wow'),
Expr.Identifier('foo'),
Expr.Identifier('coolio'),
],
}),
])
expect(parse('hello(wow)')).toEqual([
Expr.Call({ name: 'hello', args: [Expr.Identifier('wow')] }),
])
})
it('should parse sequential function calls', () => {
expect(parse('hello(world) foo-doo(bar, baz)')).toEqual([
Expr.Call({
name: 'hello',
args: [Expr.Identifier('world')],
}),
Expr.Call({
name: 'foo-doo',
args: [Expr.Identifier('bar'), Expr.Identifier('baz')],
}),
])
})
})
|