-
Notifications
You must be signed in to change notification settings - Fork 24
/
std_test.go
46 lines (41 loc) · 947 Bytes
/
std_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
package gscript
import (
"fmt"
"os"
"os/exec"
"testing"
)
func TestExec(t *testing.T) {
cmd := exec.Command("gscript", "example/print_triangle.gs")
stdoutStderr, err := cmd.CombinedOutput()
fmt.Println(string(stdoutStderr), err)
fileName := "temp.gs"
script := "println(123);"
err = os.WriteFile(fileName, []byte(script), 0666)
fmt.Println(err)
defer os.Remove(fileName)
}
func Test_Command(t *testing.T) {
Args = os.Args
script := `
System s = System();
string v = s.command("ls","-l","-h");
println(v);
v = s.command("gscript", "example/print_triangle.gs");
println(v);
`
NewCompiler().Compiler(script)
}
func Test_Write(t *testing.T) {
Args = os.Args
script := `
DateTime d = DateTime();
System s = System();
string fileName = d.unix("Asia/Shanghai") + "test.gs" ;
s.writeFile(fileName,"println(^hello^);",438);
string v = s.command("gscript",fileName);
println(v);
s.remove(fileName);
`
NewCompiler().Compiler(script)
}