compiler: add tests for starting a goroutine

This commit adds a test for both WebAssembly and Cortex-M targets (which
use a different way of goroutine lowering) to show how they lower
goroutines. It makes it easier to show how the output changes in future
commits.
This commit is contained in:
Ayke van Laethem
2021-05-25 22:33:59 +02:00
committed by Ron Evans
parent 6e1eb28ed0
commit 87c2ccb0b9
4 changed files with 314 additions and 38 deletions
+24
View File
@@ -0,0 +1,24 @@
package main
func regularFunctionGoroutine() {
go regularFunction(5)
}
func inlineFunctionGoroutine() {
go func(x int) {
}(5)
}
func closureFunctionGoroutine() {
n := 3
go func(x int) {
n = 7
}(5)
print(n) // note: this is racy (but good enough for this test)
}
func funcGoroutine(fn func(x int)) {
go fn(5)
}
func regularFunction(x int)