xgo/parser/parser_semicolon_test.go
2019-01-08 23:17:42 -08:00

45 lines
777 B
Go

package parser_test
import (
"testing"
"github.com/d5/tengo/ast"
)
func TestSemicolon(t *testing.T) {
expect(t, "1", func(p pfn) []ast.Stmt {
return stmts(
exprStmt(intLit(1, p(1, 1))))
})
expect(t, "1;", func(p pfn) []ast.Stmt {
return stmts(
exprStmt(intLit(1, p(1, 1))))
})
expect(t, "1;;", func(p pfn) []ast.Stmt {
return stmts(
exprStmt(intLit(1, p(1, 1))),
emptyStmt(false, p(1, 3)))
})
expect(t, `1
`, func(p pfn) []ast.Stmt {
return stmts(
exprStmt(intLit(1, p(1, 1))))
})
expect(t, `1
;`, func(p pfn) []ast.Stmt {
return stmts(
exprStmt(intLit(1, p(1, 1))),
emptyStmt(false, p(2, 1)))
})
expect(t, `1;
;`, func(p pfn) []ast.Stmt {
return stmts(
exprStmt(intLit(1, p(1, 1))),
emptyStmt(false, p(2, 1)))
})
}