From ed9a0c8f0f3c1eed3582d722935cd1df1d055afd Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 3 Jul 2022 18:11:55 +0200 Subject: Compile If Stmts --- pkg/lang/parser/parser_test.go | 48 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'pkg/lang/parser/parser_test.go') diff --git a/pkg/lang/parser/parser_test.go b/pkg/lang/parser/parser_test.go index f48b6a5..b756b1b 100644 --- a/pkg/lang/parser/parser_test.go +++ b/pkg/lang/parser/parser_test.go @@ -384,34 +384,38 @@ func TestIfStmt(t *testing.T) { require.Equal(t, ast.Stmt{ Kind: ast.StmtKindIf, Value: ast.StmtIf{ - Cond: ast.Expr{ - At: source.NewLoc(0, 3), - Kind: ast.ExprKindBoolLit, - Value: ast.ExprBoolLit{Value: false}, - }, - Then: ast.BlockNode{ - At: source.NewLoc(0, 9), - Stmts: []ast.Stmt{ - { - At: source.NewLoc(0, 10), - Kind: ast.StmtKindEmpty, - Value: ast.StmtEmpty{}, + Conds: []ast.CondNode{ + { + At: source.NewLoc(0, 0), + Cond: ast.Expr{ + At: source.NewLoc(0, 3), + Kind: ast.ExprKindBoolLit, + Value: ast.ExprBoolLit{Value: false}, }, - { - At: source.NewLoc(1, 1), - Kind: ast.StmtKindVarDecl, - Value: ast.StmtVarDecl{ - Name: ast.IdentNode{At: source.NewLoc(1, 5), Value: "x"}, - Value: ast.Expr{ - At: source.NewLoc(1, 9), - Kind: ast.ExprKindIntLit, - Value: ast.ExprIntLit{Value: 2}, + Then: ast.BlockNode{ + At: source.NewLoc(0, 9), + Stmts: []ast.Stmt{ + { + At: source.NewLoc(0, 10), + Kind: ast.StmtKindEmpty, + Value: ast.StmtEmpty{}, + }, + { + At: source.NewLoc(1, 1), + Kind: ast.StmtKindVarDecl, + Value: ast.StmtVarDecl{ + Name: ast.IdentNode{At: source.NewLoc(1, 5), Value: "x"}, + Value: ast.Expr{ + At: source.NewLoc(1, 9), + Kind: ast.ExprKindIntLit, + Value: ast.ExprIntLit{Value: 2}, + }, + }, }, }, }, }, }, - Elifs: []ast.CondNode{}, }, }, program.Stmts[0]) } -- cgit 1.4.1