1
0
mirror of https://github.com/golang/go synced 2024-11-08 18:36:22 -07:00
go/test/fixedbugs/issue19182.go
Richard Musiol e3c684777a all: skip unsupported tests for js/wasm
The general policy for the current state of js/wasm is that it only
has to support tests that are also supported by nacl.

The test nilptr3.go makes assumptions about which nil checks can be
removed. Since WebAssembly does not signal on reading a null pointer,
all nil checks have to be explicit.

Updates #18892

Change-Id: I06a687860b8d22ae26b1c391499c0f5183e4c485
Reviewed-on: https://go-review.googlesource.com/110096
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-30 19:39:18 +00:00

38 lines
724 B
Go

// run
// +build !js
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"runtime"
"sync/atomic"
"time"
)
var a uint64 = 0
func main() {
runtime.GOMAXPROCS(2) // With just 1, infinite loop never yields
go func() {
for {
atomic.AddUint64(&a, uint64(1))
}
}()
time.Sleep(10 * time.Millisecond) // Short sleep is enough in passing case
i, val := 0, atomic.LoadUint64(&a)
for ; val == 0 && i < 100; val, i = atomic.LoadUint64(&a), i+1 {
time.Sleep(100 * time.Millisecond)
}
if val == 0 {
fmt.Printf("Failed to observe atomic increment after %d tries\n", i)
}
}