2019-01-09 10:17:42 +03:00
|
|
|
package parser_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-01-11 13:27:28 +03:00
|
|
|
"github.com/d5/tengo/compiler/ast"
|
2019-01-09 10:17:42 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
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)))
|
|
|
|
})
|
|
|
|
}
|