Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
169e6d40
Commit
169e6d40
authored
Mar 22, 2011
by
Robert Hencke
Committed by
Rob Pike
Mar 22, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: enable tests using v, ok := <-ch syntax
R=rsc, r CC=golang-dev
https://golang.org/cl/4290059
parent
1da382c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
33 deletions
+29
-33
test/fixedbugs/bug069.go
test/fixedbugs/bug069.go
+10
-11
test/fixedbugs/bug196.go
test/fixedbugs/bug196.go
+3
-4
test/fixedbugs/bug234.go
test/fixedbugs/bug234.go
+13
-13
test/fixedbugs/bug242.go
test/fixedbugs/bug242.go
+3
-5
No files found.
test/fixedbugs/bug069.go
View file @
169e6d40
...
...
@@ -7,15 +7,14 @@
package
main
func
main
()
{
//TODO(rsc): uncomment when this syntax is valid for receive+check closed
// c := make(chan int);
// ok := false;
// var i int;
//
// i, ok = <-c; // works
// _, _ = i, ok;
//
// ca := new([2]chan int);
// i, ok = <-(ca[0]); // fails: c.go:11: bad shape across assignment - cr=1 cl=2
// _, _ = i, ok;
c
:=
make
(
chan
int
);
ok
:=
false
;
var
i
int
;
i
,
ok
=
<-
c
;
// works
_
,
_
=
i
,
ok
;
ca
:=
new
([
2
]
chan
int
);
i
,
ok
=
<-
(
ca
[
0
]);
// fails: c.go:11: bad shape across assignment - cr=1 cl=2
_
,
_
=
i
,
ok
;
}
test/fixedbugs/bug196.go
View file @
169e6d40
...
...
@@ -13,12 +13,11 @@ var i int
func
multi
()
(
int
,
int
)
{
return
1
,
2
}
func
xxx
()
{
//TODO(rsc): uncomment when this syntax is valid for receive+check closed
// var c chan int
// x, ok := <-c
var
c
chan
int
x
,
ok
:=
<-
c
var
m
map
[
int
]
int
x
,
ok
:
=
m
[
1
]
x
,
ok
=
m
[
1
]
var
i
interface
{}
var
xx
int
...
...
test/fixedbugs/bug234.go
View file @
169e6d40
...
...
@@ -7,17 +7,17 @@
package
main
func
main
()
{
//TODO(rsc): uncomment when this syntax is valid for receive+check closed
// c := make(chan int, 1)
// c <- 100
// x, ok := <-c
// if x != 100 || !ok {
// println("x=", x, " ok=", ok, " want 100, true
")
// panic("fail")
// }
//
x, ok = <-c
//
if x != 0 || ok {
//
println("x=", x, " ok=", ok, " want 0, false")
//
panic("fail")
//
}
c
:=
make
(
chan
int
,
1
)
c
<-
100
x
,
ok
:=
<-
c
if
x
!=
100
||
!
ok
{
println
(
"x="
,
x
,
" ok="
,
ok
,
" want 100, true"
)
panic
(
"fail
"
)
}
close
(
c
)
x
,
ok
=
<-
c
if
x
!=
0
||
ok
{
println
(
"x="
,
x
,
" ok="
,
ok
,
" want 0, false"
)
panic
(
"fail"
)
}
}
test/fixedbugs/bug242.go
View file @
169e6d40
...
...
@@ -101,13 +101,11 @@ func main() {
c
:=
make
(
chan
byte
,
1
)
c
<-
'C'
//TODO(rsc): uncomment when this syntax is valid for receive+check closed
// 15 16
//
*f(), p1 = <-e1(c, 16)
*
f
(),
p1
=
<-
e1
(
c
,
16
),
true
// delete uncommenting above
*
f
(),
p1
=
<-
e1
(
c
,
16
)
close
(
c
)
// 17 18
// *f(), p2 = <-e1(c, 18)
*
f
(),
p2
,
_
=
0
,
false
,
e1
(
c
,
18
)
// delete when uncommenting above
*
f
(),
p2
=
<-
e1
(
c
,
18
)
a
[
17
]
+=
'0'
if
!
p1
||
p2
{
println
(
"bad chan check"
,
i
,
p1
,
p2
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment