compiler: add go test command

This commit is contained in:
Li Jie
2024-12-31 10:53:38 +08:00
parent 6b11c100ba
commit 946f304bb2
13 changed files with 127 additions and 17 deletions

5
_demo/runtest/bar/bar.go Normal file
View File

@@ -0,0 +1,5 @@
package bar
func Bar() int {
return 2
}

View File

@@ -0,0 +1,9 @@
package bar
import "testing"
func TestBar(t *testing.T) {
if Bar() != 2 {
t.Fatal("Bar() != 2")
}
}

5
_demo/runtest/foo/foo.go Normal file
View File

@@ -0,0 +1,5 @@
package foo
func Foo() int {
return 1
}

View File

@@ -0,0 +1,9 @@
package foo
import "testing"
func TestFoo(t *testing.T) {
if Foo() != 1 {
t.Fatal("Foo() != 1")
}
}

16
_demo/runtest/main.go Normal file
View File

@@ -0,0 +1,16 @@
package main
import (
"github.com/goplus/llgo/_demo/runtest/bar"
"github.com/goplus/llgo/_demo/runtest/foo"
)
func Zoo() int {
return 3
}
func main() {
println("foo.Foo()", foo.Foo())
println("bar.Bar()", bar.Bar())
println("Zoo()", Zoo())
}

View File

@@ -0,0 +1,9 @@
package main
import "testing"
func TestZoo(t *testing.T) {
if Zoo() != 3 {
t.Fatal("Zoo() != 3")
}
}