diff options
author | Teddy Wing | 2023-05-16 19:53:19 +0200 |
---|---|---|
committer | Teddy Wing | 2023-05-16 19:53:19 +0200 |
commit | 5afcd02ea68efd3faba578bdcee853c028b14e0e (patch) | |
tree | fa5e230b7403febab284616814fa23d43c2fa70b /testdata/simple.go | |
parent | 3eef30cf630eda3837a27a237e89207e1ce3dabf (diff) | |
download | gocapturedrefrace-5afcd02ea68efd3faba578bdcee853c028b14e0e.tar.bz2 |
Add automated test
Follow `golang.org/x/tools/go/analysis/passes/testinggoroutine` to write
the test runner:
https://github.com/golang/tools/blob/1c9fe3f82c363b929ef7239ca0ad8a5dafbbcf05/go/analysis/passes/testinggoroutine/testinggoroutine_test.go
Add "want" comments to test code for validation.
Diffstat (limited to 'testdata/simple.go')
-rw-r--r-- | testdata/simple.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/testdata/simple.go b/testdata/simple.go index 76fb5d5..8002953 100644 --- a/testdata/simple.go +++ b/testdata/simple.go @@ -8,8 +8,8 @@ func main() { copied := 0 go func(copied int) { - capturedReference += 1 - capturedReference2 += 1 + capturedReference += 1 // want "captured reference capturedReference in goroutine closure" + capturedReference2 += 1 // want "captured reference capturedReference2 in goroutine closure" copied += 1 if capturedReference == 1 { @@ -36,6 +36,6 @@ func argumentReference() { s := aStruct{field: 0} go func(s *aStruct) { - s.field += 1 + s.field += 1 // want "reference s in goroutine closure" }(&s) } |