Python: добавлено прсвоение нового массива

Этот коммит содержится в:
Softonik 2022-12-08 04:26:28 +03:00 коммит произвёл Nikolay Kopitonenko
родитель dbd6fb8eac
коммит 433dde73b0
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -136,6 +136,10 @@ func handleBasicLit(bl *ast.BasicLit) string {
return bl.Value
}
func handleCompositeLit(bl *ast.CompositeLit) string {
return "[]"
}
func handleUnaryExpr(expr *ast.UnaryExpr) string {
code := expr.Op.String()
code += handleExpr(expr.X)
@ -194,6 +198,8 @@ func handleExpr(expr ast.Expr) string {
switch e := expr.(type) {
case *ast.BasicLit:
code += handleBasicLit(e)
case *ast.CompositeLit:
code += handleCompositeLit(e)
case *ast.UnaryExpr:
code += handleUnaryExpr(e)
case *ast.BinaryExpr:

Просмотреть файл

@ -98,6 +98,25 @@ main()
Compare(source, expected)
})
It("Array assignment", func() {
source := `package test
import "skidl"
func main() {
a := []any{}
a = []any{}
}
`
expected := `from skidl import *
def main():
a = []
a = []
main()
`
Compare(source, expected)
})
It("Function Declaration", func() {
source := `package test
import "skidl"