-
Notifications
You must be signed in to change notification settings - Fork 4
/
py2go_test.go
63 lines (54 loc) · 1.08 KB
/
py2go_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"bytes"
"fmt"
"io/ioutil"
"testing"
)
func TestPy2go(t *testing.T) {
fmt.Print(':', '\r', '\n', "--")
path := "res/utility.py"
//path := "res/test.py"
data, err := ioutil.ReadFile(path)
if err != nil {
fmt.Println("ReadFile fail:", path, err)
return
}
//log.Info("read len=%d", len(data))
//log.Info("%s", data)
buf := bytes.NewBuffer(data)
fmt.Println(buf.Len())
var part = new(CodePart)
part.partType = CodePart_Root
err = part.Parse(buf)
if err != nil {
fmt.Println("Parse fail:", err)
return
}
fmt.Println("tree:")
part.Print()
r := part.Translate()
fmt.Println("result:")
fmt.Println(r)
}
func TestFile(t *testing.T) {
path := "res/test.py"
err := TransPy(path)
fmt.Println(err)
}
func TestDir(t *testing.T) {
if err := ScanDir("./res/"); err != nil {
fmt.Println("ScanDir error:", err)
return
}
if err := ScanDir("./"); err != nil {
fmt.Println("ScanDir error:", err)
return
}
}
func TestSimple(t *testing.T) {
var list = []int{0, 1, 2, 3, 4}
var n = 3
list = append(list[0:n], list[n+1:]...)
fmt.Println(list)
}