Skip to content

Commit

Permalink
Add a test case for gopherjs#603.
Browse files Browse the repository at this point in the history
  • Loading branch information
nevkontakte committed Jun 19, 2021
1 parent 05447a1 commit df720d6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/goroutine_test.go
Expand Up @@ -186,3 +186,30 @@ func TestDeferWithBlocking(t *testing.T) {
fmt.Print("")
return
}

// counter, sideEffect and withBlockingDeferral are defined as top-level symbols
// to make compiler generate simplest code possible without any closures.
var counter = 0

func sideEffect() int {
counter++
return 42
}

func withBlockingDeferral() int {
defer time.Sleep(0)
return sideEffect()
}

func TestReturnWithBlockingDefer(t *testing.T) {
t.Skip("https://github.com/gopherjs/gopherjs/issues/603")
counter = 0

got := withBlockingDeferral()
if got != 42 {
t.Errorf("Unexpected return value %v. Want: 42.", got)
}
if counter != 1 {
t.Errorf("Return value was computed %d times. Want: exactly 1.", counter)
}
}

0 comments on commit df720d6

Please sign in to comment.