diff options
author | Ayke van Laethem <[email protected]> | 2019-02-28 14:11:46 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-03-23 16:16:19 +0100 |
commit | ad7297a539639af276db2c38af0940a0afdb09a6 (patch) | |
tree | 49897bba8165900ff2048239fc0d55f29104a9d7 /testdata/channel.go | |
parent | 4d82f42d61d677d0da0cda2b5bbff3d8578fc8fd (diff) | |
download | tinygo-ad7297a539639af276db2c38af0940a0afdb09a6.tar.gz tinygo-ad7297a539639af276db2c38af0940a0afdb09a6.zip |
all: implement trivial select statements
Implement two trivial uses of the select statement.
Always blocking:
select {}
No-op:
select {
default:
}
Go 1.12 added a `select {}` instruction to syscall/js, so this is needed
for Go 1.12 support. More complete support for select will be added in
the future.
Diffstat (limited to 'testdata/channel.go')
-rw-r--r-- | testdata/channel.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/testdata/channel.go b/testdata/channel.go index 3777b27a0..840255911 100644 --- a/testdata/channel.go +++ b/testdata/channel.go @@ -43,6 +43,10 @@ func main() { } println("sum(100):", sum) + // Test select + go selectDeadlock() + go selectNoOp() + // Allow goroutines to exit. time.Sleep(time.Microsecond) } @@ -93,3 +97,17 @@ func iterator(ch chan int, top int) { } close(ch) } + +func selectDeadlock() { + println("deadlocking") + select {} + println("unreachable") +} + +func selectNoOp() { + println("select no-op") + select { + default: + } + println("after no-op") +} |