Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
a703c9a9
Commit
a703c9a9
authored
Jul 16, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a couple of tests
update golden SVN=127428
parent
a6f87794
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
0 deletions
+110
-0
fifo.go
test/chan/fifo.go
+54
-0
golden.out
test/golden.out
+4
-0
utf.go
test/utf.go
+52
-0
No files found.
test/chan/fifo.go
0 → 100644
View file @
a703c9a9
// $G $D/$F.go && $L $F.$A && ./$A.out
// Copyright 2009 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.
// Verify that unbuffered channels act as pure fifos.
package
main
const
N
=
10
func
AsynchFifo
()
{
ch
:=
new
(
chan
int
,
N
);
for
i
:=
0
;
i
<
N
;
i
++
{
>
ch
=
i
}
for
i
:=
0
;
i
<
N
;
i
++
{
if
<
ch
!=
i
{
print
"bad receive
\n
"
;
sys
.
exit
(
1
);
}
}
}
func
Chain
(
ch
*
chan
<
int
,
val
int
,
in
*
chan
<
int
,
out
*
chan
>
int
)
{
BUG
:=
<
in
;
if
<
ch
!=
val
{
panic
val
;
}
>
out
=
1
;
}
// thread together a daisy chain to read the elements in sequence
func
SynchFifo
()
{
ch
:=
new
(
chan
int
);
in
:=
new
(
chan
int
);
start
:=
in
;
for
i
:=
0
;
i
<
N
;
i
++
{
out
:=
new
(
chan
int
);
go
Chain
(
ch
,
i
,
in
,
out
);
in
=
out
;
}
>
start
=
0
;
for
i
:=
0
;
i
<
N
;
i
++
{
>
ch
=
i
}
}
func
main
()
{
AsynchFifo
();
SynchFifo
();
}
test/golden.out
View file @
a703c9a9
...
...
@@ -114,6 +114,8 @@ abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz-abcxyz
=========== ken/strvar.go
=========== chan/fifo.go
=========== chan/sieve.go
=========== bugs/bug010.go
...
...
@@ -260,6 +262,8 @@ BUG: compilation should succeed
=========== bugs/bug069.go
bugs/bug069.go:12: bad shape across assignment - cr=1 cl=2
BUG: compilation should succeed
=========== bugs/bug070.go
outer loop top k 0
inner loop top i 0
...
...
test/utf.go
0 → 100644
View file @
a703c9a9
// $G $F.go && $L $F.$A && ./$A.out
// Copyright 2009 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
func
main
()
{
var
chars
[
6
]
int
;
chars
[
0
]
=
'a'
;
chars
[
1
]
=
'b'
;
chars
[
2
]
=
'c'
;
chars
[
3
]
=
'\u65e5'
;
chars
[
4
]
=
'\u672c'
;
chars
[
5
]
=
'\u8a9e'
;
s
:=
""
;
for
i
:=
0
;
i
<
6
;
i
++
{
s
+=
string
(
chars
[
i
]);
}
var
l
=
len
(
s
);
for
w
,
i
,
j
:=
0
,
0
,
0
;
i
<
l
;
i
+=
w
{
var
r
int32
;
r
,
w
=
sys
.
stringtorune
(
s
,
i
,
l
);
if
w
==
0
{
panic
"zero width in string"
}
if
r
!=
chars
[
j
]
{
panic
"wrong value from string"
}
j
++
;
}
// encoded as bytes: 'a' 'b' 'c' e6 97 a5 e6 9c ac e8 aa 9e
const
L
=
12
;
if
L
!=
l
{
panic
"wrong length constructing array"
}
a
:=
new
([
L
]
byte
);
a
[
0
]
=
'a'
;
a
[
1
]
=
'b'
;
a
[
2
]
=
'c'
;
a
[
3
]
=
0xe6
;
a
[
4
]
=
0x97
;
a
[
5
]
=
0xa5
;
a
[
6
]
=
0xe6
;
a
[
7
]
=
0x9c
;
a
[
8
]
=
0xac
;
a
[
9
]
=
0xe8
;
a
[
10
]
=
0xaa
;
a
[
11
]
=
0x9e
;
for
w
,
i
,
j
:=
0
,
0
,
0
;
i
<
L
;
i
+=
w
{
var
r
int32
;
r
,
w
=
sys
.
bytestorune
(
&
a
[
0
],
i
,
L
);
if
w
==
0
{
panic
"zero width in bytes"
}
if
r
!=
chars
[
j
]
{
panic
"wrong value from bytes"
}
j
++
;
}
}
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