1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Test case for issue 3106: Better synchronization of
6 // parser after certain syntax errors.
7
8 package main
9
10 func f() {
11 var m Mutex
12 c := MakeCond(&m)
13 percent := 0
14 const step = 10
15 for i := 0; i < 5; i++ {
16 go func() {
17 for {
18 // Emulates some useful work.
19 time.Sleep(1e8)
20 m.Lock()
21 defer
22 if /* ERROR "expected ';', found 'if'" */ percent == 100 {
23 m.Unlock()
24 break
25 }
26 percent++
27 if percent % step == 0 {
28 //c.Signal()
29 }
30 m.Unlock()
31 }
32 }()
33 }
34 for {
35 m.Lock()
36 if percent == 0 || percent % step != 0 {
37 c.Wait()
38 }
39 fmt.Print(",")
40 if percent == 100 {
41 m.Unlock()
42 break
43 }
44 m.Unlock()
45 }
46 }
47
View as plain text