diff options
Diffstat (limited to 'pkg/lang/parser/parser_test.go')
| -rw-r--r-- | pkg/lang/parser/parser_test.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/pkg/lang/parser/parser_test.go b/pkg/lang/parser/parser_test.go index de97928..24f3044 100644 --- a/pkg/lang/parser/parser_test.go +++ b/pkg/lang/parser/parser_test.go @@ -370,6 +370,55 @@ func TestMultipleStmts(t *testing.T) { require.Equal(t, expected, program.Stmts) } +func TestRepeatingNestedExpr(t *testing.T) { + src := "x.y.z()()" + + p := cheatWithScanner(t, src) + program, err := p.Parse() + require.NoError(t, err) + + require.Equal(t, 1, len(program.Stmts)) + require.Equal(t, ast.Stmt{ + At: source.NewLoc(0, 0), + Kind: ast.StmtKindExpr, + Value: ast.StmtExpr{ + Value: ast.Expr{ + At: source.NewLoc(0, 0), + Kind: ast.ExprKindCall, + Value: ast.ExprCall{ + Callee: ast.Expr{ + At: source.NewLoc(0, 0), + Kind: ast.ExprKindCall, + Value: ast.ExprCall{ + Callee: ast.Expr{ + At: source.NewLoc(0, 0), + Kind: ast.ExprKindMember, + Value: ast.ExprMember{ + Obj: ast.Expr{ + At: source.NewLoc(0, 0), + Kind: ast.ExprKindMember, + Value: ast.ExprMember{ + Obj: ast.Expr{ + At: source.NewLoc(0, 0), + Kind: ast.ExprKindIdent, + Value: ast.ExprIdent{Value: ast.IdentNode{At: source.NewLoc(0, 0), Value: "x"}}, + }, + Key: ast.IdentNode{At: source.NewLoc(0, 2), Value: "y"}, + }, + }, + Key: ast.IdentNode{At: source.NewLoc(0, 4), Value: "z"}, + }, + }, + Args: []ast.Expr{}, + }, + }, + Args: []ast.Expr{}, + }, + }, + }, + }, program.Stmts[0]) +} + func TestIfStmt(t *testing.T) { src := sourceify( `if false {`, |
