aboutsummaryrefslogtreecommitdiffhomepage
path: root/testdata
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2021-10-24 20:58:03 +0200
committerRon Evans <[email protected]>2021-10-31 14:17:25 +0100
commit9e1b4de999c0f2f98d777b10d6660343b208bea6 (patch)
tree60de58a51e870335304011eec09270f5473b1bee /testdata
parenta4afc3b4b085b78d9da6038388eae54a7b1776be (diff)
downloadtinygo-9e1b4de999c0f2f98d777b10d6660343b208bea6.tar.gz
tinygo-9e1b4de999c0f2f98d777b10d6660343b208bea6.zip
compiler: add support for the `go` keyword on interface methods
This is a feature that was long missing, but because of the previous refactor, it is now trivial to implement.
Diffstat (limited to 'testdata')
-rw-r--r--testdata/goroutines.go27
-rw-r--r--testdata/goroutines.txt4
2 files changed, 31 insertions, 0 deletions
diff --git a/testdata/goroutines.go b/testdata/goroutines.go
index e3cc62fa7..eb38a5b1f 100644
--- a/testdata/goroutines.go
+++ b/testdata/goroutines.go
@@ -75,6 +75,8 @@ func main() {
testGoOnBuiltins()
+ testGoOnInterface(Foo(0))
+
testCond()
testIssue1790()
@@ -203,6 +205,14 @@ func testCond() {
var once sync.Once
+func testGoOnInterface(f Itf) {
+ go f.Nowait()
+ time.Sleep(time.Millisecond)
+ go f.Wait()
+ time.Sleep(time.Millisecond * 2)
+ println("done with 'go on interface'")
+}
+
// This tests a fix for issue 1790:
// https://github.com/tinygo-org/tinygo/issues/1790
func testIssue1790() *int {
@@ -210,3 +220,20 @@ func testIssue1790() *int {
i := 0
return &i
}
+
+type Itf interface {
+ Nowait()
+ Wait()
+}
+
+type Foo string
+
+func (f Foo) Nowait() {
+ println("called: Foo.Nowait")
+}
+
+func (f Foo) Wait() {
+ println("called: Foo.Wait")
+ time.Sleep(time.Microsecond)
+ println(" ...waited")
+}
diff --git a/testdata/goroutines.txt b/testdata/goroutines.txt
index 1e29558af..b2debbb11 100644
--- a/testdata/goroutines.txt
+++ b/testdata/goroutines.txt
@@ -20,3 +20,7 @@ acquired mutex from goroutine
released mutex from goroutine
re-acquired mutex
done
+called: Foo.Nowait
+called: Foo.Wait
+ ...waited
+done with 'go on interface'