diff --git a/parser/parser_test.go b/parser/parser_test.go index bc2bffed..727d83c0 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -1110,15 +1110,16 @@ func TestPosition(t *testing.T) { is(node.Idx0(), 40) is(parser.slice(node.Idx0(), node.Idx1()), "break") - parser = newParser("", "xyz: for (i = 0; i < 10; i++) { if (i == 5) continue xyz; }", 1, nil) + parser = newParser("", "(function(){ xyz: for (i = 0; i < 10; i++) { if (i == 5) continue xyz; } })", 1, nil) program, err = parser.parse() is(err, nil) - node = program.Body[0].(*ast.LabelledStatement) - is(node.Idx0(), 1) + block = program.Body[0].(*ast.ExpressionStatement).Expression.(*ast.FunctionLiteral).Body.(*ast.BlockStatement) + node = block.List[0].(*ast.LabelledStatement) + is(node.Idx0(), 14) is(parser.slice(node.Idx0(), node.Idx1()), "xyz: for (i = 0; i < 10; i++) { if (i == 5) continue xyz; }") - block = program.Body[0].(*ast.LabelledStatement).Statement.(*ast.ForStatement).Body.(*ast.BlockStatement) + block = node.(*ast.LabelledStatement).Statement.(*ast.ForStatement).Body.(*ast.BlockStatement) node = block.List[0].(*ast.IfStatement).Consequent.(*ast.BranchStatement) - is(node.Idx0(), 45) + is(node.Idx0(), 58) is(parser.slice(node.Idx0(), node.Idx1()), "continue xyz") parser = newParser("", "(function(){ return; })", 1, nil)