mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 03:53:42 +00:00
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:
committed by
Ron Evans
parent
6e1eb28ed0
commit
87c2ccb0b9
Vendored
+24
@@ -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)
|
||||
Reference in New Issue
Block a user