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
ae54cf73
Commit
ae54cf73
authored
Sep 15, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
last round: non-package code
R=r DELTA=127 (38 added, 3 deleted, 86 changed) OCL=34640 CL=34650
parent
8cb9184d
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
116 additions
and
81 deletions
+116
-81
doc/progs/sortmain.go
doc/progs/sortmain.go
+1
-1
test/assign.go
test/assign.go
+4
-0
test/bench/chameneosredux.go
test/bench/chameneosredux.go
+1
-1
test/bench/regex-dna.go
test/bench/regex-dna.go
+2
-2
test/bugs/bug193.go
test/bugs/bug193.go
+1
-0
test/chan/perm.go
test/chan/perm.go
+9
-0
test/decl.go
test/decl.go
+1
-0
test/declbad.go
test/declbad.go
+7
-0
test/escape.go
test/escape.go
+1
-1
test/fixedbugs/bug022.go
test/fixedbugs/bug022.go
+1
-0
test/fixedbugs/bug030.go
test/fixedbugs/bug030.go
+1
-0
test/fixedbugs/bug047.go
test/fixedbugs/bug047.go
+2
-0
test/fixedbugs/bug048.go
test/fixedbugs/bug048.go
+1
-0
test/fixedbugs/bug056.go
test/fixedbugs/bug056.go
+1
-0
test/fixedbugs/bug065.go
test/fixedbugs/bug065.go
+1
-0
test/fixedbugs/bug143.go
test/fixedbugs/bug143.go
+6
-3
test/fixedbugs/bug146.go
test/fixedbugs/bug146.go
+1
-0
test/fixedbugs/bug152.go
test/fixedbugs/bug152.go
+1
-1
test/fixedbugs/bug173.go
test/fixedbugs/bug173.go
+2
-2
test/fixedbugs/bug183.go
test/fixedbugs/bug183.go
+4
-2
test/fixedbugs/bug184.go
test/fixedbugs/bug184.go
+2
-0
test/fixedbugs/bug189.go
test/fixedbugs/bug189.go
+1
-0
test/fixedbugs/bug201.go
test/fixedbugs/bug201.go
+6
-6
test/fixedbugs/bug204.go
test/fixedbugs/bug204.go
+1
-1
test/initialize.go
test/initialize.go
+1
-1
test/mallocrep1.go
test/mallocrep1.go
+1
-1
test/map.go
test/map.go
+54
-57
test/range.go
test/range.go
+1
-1
usr/dsymonds/iterable/iterable_test.go
usr/dsymonds/iterable/iterable_test.go
+1
-1
No files found.
doc/progs/sortmain.go
View file @
ae54cf73
...
@@ -55,7 +55,7 @@ func days() {
...
@@ -55,7 +55,7 @@ func days() {
if
!
sort
.
IsSorted
(
&
a
)
{
if
!
sort
.
IsSorted
(
&
a
)
{
panic
()
panic
()
}
}
for
i
,
d
:=
range
data
{
for
_
,
d
:=
range
data
{
fmt
.
Printf
(
"%s "
,
d
.
long_name
)
fmt
.
Printf
(
"%s "
,
d
.
long_name
)
}
}
fmt
.
Printf
(
"
\n
"
)
fmt
.
Printf
(
"
\n
"
)
...
...
test/assign.go
View file @
ae54cf73
...
@@ -17,17 +17,21 @@ func main() {
...
@@ -17,17 +17,21 @@ func main() {
{
{
var
x
,
y
sync
.
Mutex
;
var
x
,
y
sync
.
Mutex
;
x
=
y
;
// ERROR "assignment\[ -~\]*Mutex"
x
=
y
;
// ERROR "assignment\[ -~\]*Mutex"
_
=
x
;
}
}
{
{
var
x
,
y
T
;
var
x
,
y
T
;
x
=
y
;
// ERROR "assignment\[ -~\]*Mutex"
x
=
y
;
// ERROR "assignment\[ -~\]*Mutex"
_
=
x
;
}
}
{
{
var
x
,
y
[
2
]
sync
.
Mutex
;
var
x
,
y
[
2
]
sync
.
Mutex
;
x
=
y
;
// ERROR "assignment\[ -~\]*Mutex"
x
=
y
;
// ERROR "assignment\[ -~\]*Mutex"
_
=
x
;
}
}
{
{
var
x
,
y
[
2
]
T
;
var
x
,
y
[
2
]
T
;
x
=
y
;
// ERROR "assignment\[ -~\]*Mutex"
x
=
y
;
// ERROR "assignment\[ -~\]*Mutex"
_
=
x
;
}
}
}
}
test/bench/chameneosredux.go
View file @
ae54cf73
...
@@ -175,7 +175,7 @@ func play(ref *Referee, color []Color) {
...
@@ -175,7 +175,7 @@ func play(ref *Referee, color []Color) {
fmt
.
Printf
(
"
\n
"
);
fmt
.
Printf
(
"
\n
"
);
<-
ref
.
done
;
<-
ref
.
done
;
total
:=
0
;
total
:=
0
;
for
i
,
c
:=
range
cham
{
for
_
,
c
:=
range
cham
{
total
+=
c
.
count
;
total
+=
c
.
count
;
fmt
.
Printf
(
"%d %s
\n
"
,
c
.
count
,
say
(
c
.
same
));
fmt
.
Printf
(
"%d %s
\n
"
,
c
.
count
,
say
(
c
.
same
));
}
}
...
...
test/bench/regex-dna.go
View file @
ae54cf73
...
@@ -106,10 +106,10 @@ func main() {
...
@@ -106,10 +106,10 @@ func main() {
// Delete the comment lines and newlines
// Delete the comment lines and newlines
bytes
=
compile
(
"(>[^
\n
]+)?
\n
"
)
.
ReplaceAll
(
bytes
,
[]
byte
{});
bytes
=
compile
(
"(>[^
\n
]+)?
\n
"
)
.
ReplaceAll
(
bytes
,
[]
byte
{});
clen
:=
len
(
bytes
);
clen
:=
len
(
bytes
);
for
i
,
s
:=
range
variants
{
for
_
,
s
:=
range
variants
{
fmt
.
Printf
(
"%s %d
\n
"
,
s
,
countMatches
(
s
,
bytes
));
fmt
.
Printf
(
"%s %d
\n
"
,
s
,
countMatches
(
s
,
bytes
));
}
}
for
i
,
sub
:=
range
substs
{
for
_
,
sub
:=
range
substs
{
bytes
=
compile
(
sub
.
pat
)
.
ReplaceAll
(
bytes
,
strings
.
Bytes
(
sub
.
repl
));
bytes
=
compile
(
sub
.
pat
)
.
ReplaceAll
(
bytes
,
strings
.
Bytes
(
sub
.
repl
));
}
}
fmt
.
Printf
(
"
\n
%d
\n
%d
\n
%d
\n
"
,
ilen
,
clen
,
len
(
bytes
));
fmt
.
Printf
(
"
\n
%d
\n
%d
\n
%d
\n
"
,
ilen
,
clen
,
len
(
bytes
));
...
...
test/bugs/bug193.go
View file @
ae54cf73
...
@@ -12,4 +12,5 @@ func main() {
...
@@ -12,4 +12,5 @@ func main() {
y1
:=
float
(
ss
);
y1
:=
float
(
ss
);
y2
:=
float
(
1
<<
s
);
// ERROR "shift"
y2
:=
float
(
1
<<
s
);
// ERROR "shift"
y3
:=
string
(
1
<<
s
);
// ERROR "shift"
y3
:=
string
(
1
<<
s
);
// ERROR "shift"
_
,
_
,
_
,
_
,
_
=
s
,
ss
,
y1
,
y2
,
y3
;
}
}
test/chan/perm.go
View file @
ae54cf73
...
@@ -22,27 +22,36 @@ func main() {
...
@@ -22,27 +22,36 @@ func main() {
c
<-
0
;
// ok
c
<-
0
;
// ok
ok
:=
c
<-
0
;
// ok
ok
:=
c
<-
0
;
// ok
_
=
ok
;
<-
c
;
// ok
<-
c
;
// ok
x
,
ok
:=
<-
c
;
// ok
x
,
ok
:=
<-
c
;
// ok
_
,
_
=
x
,
ok
;
cr
<-
0
;
// ERROR "send"
cr
<-
0
;
// ERROR "send"
ok
=
cr
<-
0
;
// ERROR "send"
ok
=
cr
<-
0
;
// ERROR "send"
_
=
ok
;
<-
cr
;
// ok
<-
cr
;
// ok
x
,
ok
=
<-
cr
;
// ok
x
,
ok
=
<-
cr
;
// ok
_
,
_
=
x
,
ok
;
cs
<-
0
;
// ok
cs
<-
0
;
// ok
ok
=
cs
<-
0
;
// ok
ok
=
cs
<-
0
;
// ok
_
=
ok
;
<-
cs
;
// ERROR "receive"
<-
cs
;
// ERROR "receive"
x
,
ok
=
<-
cs
;
// ERROR "receive"
x
,
ok
=
<-
cs
;
// ERROR "receive"
_
,
_
=
x
,
ok
;
select
{
select
{
case
c
<-
0
:
// ok
case
c
<-
0
:
// ok
case
x
:=
<-
c
:
// ok
case
x
:=
<-
c
:
// ok
_
=
x
;
case
cr
<-
0
:
// ERROR "send"
case
cr
<-
0
:
// ERROR "send"
case
x
:=
<-
cr
:
// ok
case
x
:=
<-
cr
:
// ok
_
=
x
;
case
cs
<-
0
:
// ok;
case
cs
<-
0
:
// ok;
case
x
:=
<-
cs
:
// ERROR "receive"
case
x
:=
<-
cs
:
// ERROR "receive"
_
=
x
;
}
}
}
}
test/decl.go
View file @
ae54cf73
...
@@ -14,6 +14,7 @@ func f3() (float, int, string) { return 1, 2, "3" }
...
@@ -14,6 +14,7 @@ func f3() (float, int, string) { return 1, 2, "3" }
func
x
()
(
s
string
)
{
func
x
()
(
s
string
)
{
a
,
b
,
s
:=
f3
();
a
,
b
,
s
:=
f3
();
_
,
_
=
a
,
b
;
return
// tests that result var is in scope for redeclaration
return
// tests that result var is in scope for redeclaration
}
}
...
...
test/declbad.go
View file @
ae54cf73
...
@@ -17,35 +17,42 @@ func main() {
...
@@ -17,35 +17,42 @@ func main() {
// simple redeclaration
// simple redeclaration
i
:=
f1
();
i
:=
f1
();
i
:=
f1
();
// ERROR "redeclared|no new"
i
:=
f1
();
// ERROR "redeclared|no new"
_
=
i
;
}
}
{
{
// change of type for f
// change of type for f
i
,
f
,
s
:=
f3
();
i
,
f
,
s
:=
f3
();
f
,
g
,
t
:=
f3
();
// ERROR "redeclared|cannot assign|incompatible"
f
,
g
,
t
:=
f3
();
// ERROR "redeclared|cannot assign|incompatible"
_
,
_
,
_
,
_
,
_
=
i
,
f
,
s
,
g
,
t
;
}
}
{
{
// change of type for i
// change of type for i
i
,
f
,
s
:=
f3
();
i
,
f
,
s
:=
f3
();
j
,
i
,
t
:=
f3
();
// ERROR "redeclared|cannot assign|incompatible"
j
,
i
,
t
:=
f3
();
// ERROR "redeclared|cannot assign|incompatible"
_
,
_
,
_
,
_
,
_
=
i
,
f
,
s
,
j
,
t
;
}
}
{
{
// no new variables
// no new variables
i
,
f
,
s
:=
f3
();
i
,
f
,
s
:=
f3
();
i
,
f
:=
f2
();
// ERROR "redeclared|no new"
i
,
f
:=
f2
();
// ERROR "redeclared|no new"
_
,
_
,
_
=
i
,
f
,
s
;
}
}
{
{
// single redeclaration
// single redeclaration
i
,
f
,
s
:=
f3
();
i
,
f
,
s
:=
f3
();
i
:=
f1
();
// ERROR "redeclared|no new|incompatible"
i
:=
f1
();
// ERROR "redeclared|no new|incompatible"
_
,
_
,
_
=
i
,
f
,
s
;
}
}
// double redeclaration
// double redeclaration
{
{
i
,
f
,
s
:=
f3
();
i
,
f
,
s
:=
f3
();
i
,
f
:=
f2
();
// ERROR "redeclared|no new"
i
,
f
:=
f2
();
// ERROR "redeclared|no new"
_
,
_
,
_
=
i
,
f
,
s
;
}
}
{
{
// triple redeclaration
// triple redeclaration
i
,
f
,
s
:=
f3
();
i
,
f
,
s
:=
f3
();
i
,
f
,
s
:=
f3
();
// ERROR "redeclared|no new"
i
,
f
,
s
:=
f3
();
// ERROR "redeclared|no new"
_
,
_
,
_
=
i
,
f
,
s
;
}
}
}
}
test/escape.go
View file @
ae54cf73
...
@@ -112,7 +112,7 @@ func select_escapes1(x int, y int) (*int, *int) {
...
@@ -112,7 +112,7 @@ func select_escapes1(x int, y int) (*int, *int) {
func
range_escapes
(
x
int
)
*
int
{
func
range_escapes
(
x
int
)
*
int
{
var
a
[
1
]
int
;
var
a
[
1
]
int
;
a
[
0
]
=
x
;
a
[
0
]
=
x
;
for
k
,
v
:=
range
a
{
for
_
,
v
:=
range
a
{
return
&
v
;
return
&
v
;
}
}
return
nil
;
return
nil
;
...
...
test/fixedbugs/bug022.go
View file @
ae54cf73
...
@@ -10,6 +10,7 @@ func putint(digits *string) {
...
@@ -10,6 +10,7 @@ func putint(digits *string) {
var
i
byte
;
var
i
byte
;
i
=
(
*
digits
)[
7
];
// compiles
i
=
(
*
digits
)[
7
];
// compiles
i
=
digits
[
7
];
// ERROR "illegal|is not|invalid"
i
=
digits
[
7
];
// ERROR "illegal|is not|invalid"
_
=
i
;
}
}
func
main
()
{
func
main
()
{
...
...
test/fixedbugs/bug030.go
View file @
ae54cf73
...
@@ -9,4 +9,5 @@ package main
...
@@ -9,4 +9,5 @@ package main
func
main
()
{
func
main
()
{
var
x
int
;
var
x
int
;
x
:=
0
;
// ERROR "declar|:="
x
:=
0
;
// ERROR "declar|:="
_
=
x
;
}
}
test/fixedbugs/bug047.go
View file @
ae54cf73
...
@@ -18,4 +18,6 @@ func main() {
...
@@ -18,4 +18,6 @@ func main() {
type
M
map
[
int
]
int
;
type
M
map
[
int
]
int
;
m0
:=
M
{
7
:
8
};
m0
:=
M
{
7
:
8
};
_
,
_
=
t
,
m0
;
}
}
test/fixedbugs/bug048.go
View file @
ae54cf73
...
@@ -9,4 +9,5 @@ package main
...
@@ -9,4 +9,5 @@ package main
func
main
()
{
func
main
()
{
type
M
map
[
int
]
int
;
type
M
map
[
int
]
int
;
m1
:=
M
{
7
:
8
};
m1
:=
M
{
7
:
8
};
_
=
m1
;
}
}
test/fixedbugs/bug056.go
View file @
ae54cf73
...
@@ -12,6 +12,7 @@ func frexp() (a int, b float64) {
...
@@ -12,6 +12,7 @@ func frexp() (a int, b float64) {
func
main
()
{
func
main
()
{
a
,
b
:=
frexp
();
a
,
b
:=
frexp
();
_
,
_
=
a
,
b
;
}
}
/*
/*
...
...
test/fixedbugs/bug065.go
View file @
ae54cf73
...
@@ -8,4 +8,5 @@ package main
...
@@ -8,4 +8,5 @@ package main
func
main
()
{
func
main
()
{
k
,
l
,
m
:=
0
,
0
,
0
;
k
,
l
,
m
:=
0
,
0
,
0
;
_
,
_
,
_
=
k
,
l
,
m
;
}
}
test/fixedbugs/bug143.go
View file @
ae54cf73
...
@@ -18,13 +18,16 @@ func main() {
...
@@ -18,13 +18,16 @@ func main() {
mp
:=
&
m
;
mp
:=
&
m
;
{
{
x
,
ok
:=
m
[
"key"
]
x
,
ok
:=
m
[
"key"
];
_
,
_
=
x
,
ok
;
}
}
{
{
x
,
ok
:=
(
*
mp
)[
"key"
]
x
,
ok
:=
(
*
mp
)[
"key"
];
_
,
_
=
x
,
ok
;
}
}
{
{
x
,
ok
:=
f
()[
"key"
]
x
,
ok
:=
f
()[
"key"
];
_
,
_
=
x
,
ok
;
}
}
{
{
var
x
int
;
var
x
int
;
...
...
test/fixedbugs/bug146.go
View file @
ae54cf73
...
@@ -11,4 +11,5 @@ func main() {
...
@@ -11,4 +11,5 @@ func main() {
a
:=
[
...
]
byte
{
0
};
a
:=
[
...
]
byte
{
0
};
b
:=
Slice
(
&
a
);
// This should be OK.
b
:=
Slice
(
&
a
);
// This should be OK.
c
:=
Slice
(
a
);
// ERROR "invalid|illegal|cannot"
c
:=
Slice
(
a
);
// ERROR "invalid|illegal|cannot"
_
,
_
=
b
,
c
;
}
}
test/fixedbugs/bug152.go
View file @
ae54cf73
...
@@ -8,7 +8,7 @@ package main
...
@@ -8,7 +8,7 @@ package main
func
main
()
{
func
main
()
{
s
:=
0
;
s
:=
0
;
for
i
,
v
:=
range
[]
int
{
1
}
{
for
_
,
v
:=
range
[]
int
{
1
}
{
s
+=
v
;
s
+=
v
;
}
}
if
s
!=
1
{
if
s
!=
1
{
...
...
test/fixedbugs/bug173.go
View file @
ae54cf73
...
@@ -14,8 +14,8 @@ type T string
...
@@ -14,8 +14,8 @@ type T string
func
main
()
{
func
main
()
{
var
t
T
=
"hello"
;
var
t
T
=
"hello"
;
println
(
t
[
0
:
4
],
t
[
4
]);
println
(
t
[
0
:
4
],
t
[
4
]);
for
i
,
x
:
=
range
t
{
for
_
,
_
=
range
t
{
}
}
for
i
:
=
range
t
{
for
_
=
range
t
{
}
}
}
}
test/fixedbugs/bug183.go
View file @
ae54cf73
...
@@ -11,7 +11,8 @@ type T int
...
@@ -11,7 +11,8 @@ type T int
func
f
()
{
func
f
()
{
var
x
struct
{
T
};
var
x
struct
{
T
};
var
y
struct
{
T
T
};
var
y
struct
{
T
T
};
x
=
y
// ERROR "cannot|incompatible"
x
=
y
;
// ERROR "cannot|incompatible"
_
=
x
;
}
}
type
T1
struct
{
T
}
type
T1
struct
{
T
}
...
@@ -20,6 +21,7 @@ type T2 struct { T T }
...
@@ -20,6 +21,7 @@ type T2 struct { T T }
func
g
()
{
func
g
()
{
var
x
T1
;
var
x
T1
;
var
y
T2
;
var
y
T2
;
x
=
y
// ERROR "cannot|incompatible"
x
=
y
;
// ERROR "cannot|incompatible"
_
=
x
;
}
}
test/fixedbugs/bug184.go
View file @
ae54cf73
...
@@ -39,9 +39,11 @@ func fmter() (s string, i int, t string) {
...
@@ -39,9 +39,11 @@ func fmter() (s string, i int, t string) {
func
main
()
{
func
main
()
{
b
:=
g
();
b
:=
g
();
bb
,
ok
:=
b
.
(
*
Buffer
);
bb
,
ok
:=
b
.
(
*
Buffer
);
_
,
_
,
_
=
b
,
bb
,
ok
;
b
,
ok
=
i
();
b
,
ok
=
i
();
bb
,
ok
=
b
.
(
*
Buffer
);
bb
,
ok
=
b
.
(
*
Buffer
);
_
,
_
,
_
=
b
,
bb
,
ok
;
s
:=
fmt
.
Sprintf
(
fmter
());
s
:=
fmt
.
Sprintf
(
fmter
());
if
s
!=
"0x64
\"
hello
\"
"
{
if
s
!=
"0x64
\"
hello
\"
"
{
...
...
test/fixedbugs/bug189.go
View file @
ae54cf73
...
@@ -14,4 +14,5 @@ func main() {
...
@@ -14,4 +14,5 @@ func main() {
s1
:=
S
{
a
:
7
};
// ok - field is named
s1
:=
S
{
a
:
7
};
// ok - field is named
s3
:=
S
{
7
,
11
};
// ok - all fields have values
s3
:=
S
{
7
,
11
};
// ok - all fields have values
s2
:=
S
{
7
};
// ERROR "too few"
s2
:=
S
{
7
};
// ERROR "too few"
_
,
_
,
_
=
s1
,
s3
,
s2
;
}
}
test/fixedbugs/bug201.go
View file @
ae54cf73
...
@@ -16,18 +16,18 @@ func (MyInt) m(*T1) { }
...
@@ -16,18 +16,18 @@ func (MyInt) m(*T1) { }
func
main
()
{
func
main
()
{
{
{
var
i
interface
{}
=
new
(
T1
);
var
i
interface
{}
=
new
(
T1
);
v1
,
ok1
:=
i
.
(
*
T1
);
_
,
ok1
:=
i
.
(
*
T1
);
v2
,
ok2
:=
i
.
(
*
T2
);
_
,
ok2
:=
i
.
(
*
T2
);
v3
,
ok3
:=
i
.
(
*
T3
);
_
,
ok3
:=
i
.
(
*
T3
);
if
!
ok1
||
ok2
||
ok3
{
if
!
ok1
||
ok2
||
ok3
{
panicln
(
"*T1"
,
ok1
,
ok2
,
ok3
);
panicln
(
"*T1"
,
ok1
,
ok2
,
ok3
);
}
}
}
}
{
{
var
i
interface
{}
=
MyInt
(
0
);
var
i
interface
{}
=
MyInt
(
0
);
v1
,
ok1
:=
i
.
(
interface
{
m
(
*
T1
)
});
_
,
ok1
:=
i
.
(
interface
{
m
(
*
T1
)
});
v2
,
ok2
:=
i
.
(
interface
{
m
(
*
T2
)
});
_
,
ok2
:=
i
.
(
interface
{
m
(
*
T2
)
});
v3
,
ok3
:=
i
.
(
interface
{
m
(
*
T3
)
});
_
,
ok3
:=
i
.
(
interface
{
m
(
*
T3
)
});
if
!
ok1
||
ok2
||
ok3
{
if
!
ok1
||
ok2
||
ok3
{
panicln
(
"T"
,
ok1
,
ok2
,
ok3
);
panicln
(
"T"
,
ok1
,
ok2
,
ok3
);
}
}
...
...
test/fixedbugs/bug204.go
View file @
ae54cf73
...
@@ -9,7 +9,7 @@ package main
...
@@ -9,7 +9,7 @@ package main
func
main
()
{
func
main
()
{
nchar
:=
0
;
nchar
:=
0
;
a
:=
[]
int
{
'日'
,
'本'
,
'語'
,
0xFFFD
};
a
:=
[]
int
{
'日'
,
'本'
,
'語'
,
0xFFFD
};
for
pos
,
char
:=
range
"日本語
\xc0
"
{
for
_
,
char
:=
range
"日本語
\xc0
"
{
if
nchar
>=
len
(
a
)
{
if
nchar
>=
len
(
a
)
{
println
(
"BUG"
);
println
(
"BUG"
);
break
;
break
;
...
...
test/initialize.go
View file @
ae54cf73
...
@@ -50,7 +50,7 @@ var same = []Same {
...
@@ -50,7 +50,7 @@ var same = []Same {
func
main
()
{
func
main
()
{
ok
:=
true
;
ok
:=
true
;
for
i
,
s
:=
range
same
{
for
_
,
s
:=
range
same
{
if
!
reflect
.
DeepEqual
(
s
.
a
,
s
.
b
)
{
if
!
reflect
.
DeepEqual
(
s
.
a
,
s
.
b
)
{
ok
=
false
;
ok
=
false
;
fmt
.
Printf
(
"not same: %v and %v
\n
"
,
s
.
a
,
s
.
b
);
fmt
.
Printf
(
"not same: %v and %v
\n
"
,
s
.
a
,
s
.
b
);
...
...
test/mallocrep1.go
View file @
ae54cf73
...
@@ -87,7 +87,7 @@ func AllocAndFree(size, count int) {
...
@@ -87,7 +87,7 @@ func AllocAndFree(size, count int) {
}
}
func
atoi
(
s
string
)
int
{
func
atoi
(
s
string
)
int
{
i
,
xx1
:=
strconv
.
Atoi
(
s
);
i
,
_
:=
strconv
.
Atoi
(
s
);
return
i
return
i
}
}
...
...
test/map.go
View file @
ae54cf73
...
@@ -140,7 +140,6 @@ func main() {
...
@@ -140,7 +140,6 @@ func main() {
s
:=
strconv
.
Itoa
(
i
);
s
:=
strconv
.
Itoa
(
i
);
s10
:=
strconv
.
Itoa
(
i
*
10
);
s10
:=
strconv
.
Itoa
(
i
*
10
);
f
:=
float
(
i
);
f
:=
float
(
i
);
t
:=
T
{
int64
(
i
),
f
};
// BUG m := M(i, i+1);
// BUG m := M(i, i+1);
if
mib
[
i
]
!=
(
i
!=
0
)
{
if
mib
[
i
]
!=
(
i
!=
0
)
{
fmt
.
Printf
(
"mib[%d] = %t
\n
"
,
i
,
mib
[
i
]);
fmt
.
Printf
(
"mib[%d] = %t
\n
"
,
i
,
mib
[
i
]);
...
@@ -193,133 +192,132 @@ func main() {
...
@@ -193,133 +192,132 @@ func main() {
for
i
:=
0
;
i
<
count
;
i
++
{
for
i
:=
0
;
i
<
count
;
i
++
{
s
:=
strconv
.
Itoa
(
i
);
s
:=
strconv
.
Itoa
(
i
);
f
:=
float
(
i
);
f
:=
float
(
i
);
t
:=
T
{
int64
(
i
),
f
};
{
{
a
,
b
:=
mib
[
i
];
_
,
b
:=
mib
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mib[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mib[%d]
\n
"
,
i
);
}
}
a
,
b
=
mib
[
i
];
_
,
b
=
mib
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mib[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mib[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mii
[
i
];
_
,
b
:=
mii
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mii[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mii[%d]
\n
"
,
i
);
}
}
a
,
b
=
mii
[
i
];
_
,
b
=
mii
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mii[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mii[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mfi
[
f
];
_
,
b
:=
mfi
[
f
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mfi[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mfi[%d]
\n
"
,
i
);
}
}
a
,
b
=
mfi
[
f
];
_
,
b
=
mfi
[
f
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mfi[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mfi[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mif
[
i
];
_
,
b
:=
mif
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mif[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mif[%d]
\n
"
,
i
);
}
}
a
,
b
=
mif
[
i
];
_
,
b
=
mif
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mif[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mif[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mis
[
i
];
_
,
b
:=
mis
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mis[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mis[%d]
\n
"
,
i
);
}
}
a
,
b
=
mis
[
i
];
_
,
b
=
mis
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mis[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mis[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
msi
[
s
];
_
,
b
:=
msi
[
s
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: msi[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: msi[%d]
\n
"
,
i
);
}
}
a
,
b
=
msi
[
s
];
_
,
b
=
msi
[
s
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: msi[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: msi[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mss
[
s
];
_
,
b
:=
mss
[
s
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mss[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mss[%d]
\n
"
,
i
);
}
}
a
,
b
=
mss
[
s
];
_
,
b
=
mss
[
s
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mss[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mss[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mspa
[
s
];
_
,
b
:=
mspa
[
s
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mspa[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mspa[%d]
\n
"
,
i
);
}
}
a
,
b
=
mspa
[
s
];
_
,
b
=
mspa
[
s
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mspa[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mspa[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mipT
[
i
];
_
,
b
:=
mipT
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mipT[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mipT[%d]
\n
"
,
i
);
}
}
a
,
b
=
mipT
[
i
];
_
,
b
=
mipT
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mipT[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mipT[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mpTi
[
apT
[
i
]];
_
,
b
:=
mpTi
[
apT
[
i
]];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mpTi[apT[%d]]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mpTi[apT[%d]]
\n
"
,
i
);
}
}
a
,
b
=
mpTi
[
apT
[
i
]];
_
,
b
=
mpTi
[
apT
[
i
]];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mpTi[apT[%d]]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mpTi[apT[%d]]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mipM
[
i
];
_
,
b
:=
mipM
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mipM[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mipM[%d]
\n
"
,
i
);
}
}
a
,
b
=
mipM
[
i
];
_
,
b
=
mipM
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mipM[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mipM[%d]
\n
"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mit
[
i
];
_
,
b
:=
mit
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence decl: mit[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence decl: mit[%d]
\n
"
,
i
);
}
}
a
,
b
=
mit
[
i
];
_
,
b
=
mit
[
i
];
if
!
b
{
if
!
b
{
fmt
.
Printf
(
"tuple existence assign: mit[%d]
\n
"
,
i
);
fmt
.
Printf
(
"tuple existence assign: mit[%d]
\n
"
,
i
);
}
}
}
}
// {
// {
//
a
, b := mti[t];
//
_
, b := mti[t];
// if !b {
// if !b {
// fmt.Printf("tuple existence decl: mti[%d]\n", i);
// fmt.Printf("tuple existence decl: mti[%d]\n", i);
// }
// }
//
a
, b = mti[t];
//
_
, b = mti[t];
// if !b {
// if !b {
// fmt.Printf("tuple existence assign: mti[%d]\n", i);
// fmt.Printf("tuple existence assign: mti[%d]\n", i);
// }
// }
...
@@ -331,133 +329,132 @@ func main() {
...
@@ -331,133 +329,132 @@ func main() {
for
i
:=
count
;
i
<
2
*
count
;
i
++
{
for
i
:=
count
;
i
<
2
*
count
;
i
++
{
s
:=
strconv
.
Itoa
(
i
);
s
:=
strconv
.
Itoa
(
i
);
f
:=
float
(
i
);
f
:=
float
(
i
);
t
:=
T
{
int64
(
i
),
f
};
{
{
a
,
b
:=
mib
[
i
];
_
,
b
:=
mib
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mib[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mib[%d]"
,
i
);
}
}
a
,
b
=
mib
[
i
];
_
,
b
=
mib
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mib[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mib[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mii
[
i
];
_
,
b
:=
mii
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mii[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mii[%d]"
,
i
);
}
}
a
,
b
=
mii
[
i
];
_
,
b
=
mii
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mii[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mii[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mfi
[
f
];
_
,
b
:=
mfi
[
f
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mfi[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mfi[%d]"
,
i
);
}
}
a
,
b
=
mfi
[
f
];
_
,
b
=
mfi
[
f
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mfi[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mfi[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mif
[
i
];
_
,
b
:=
mif
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mif[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mif[%d]"
,
i
);
}
}
a
,
b
=
mif
[
i
];
_
,
b
=
mif
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mif[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mif[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mis
[
i
];
_
,
b
:=
mis
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mis[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mis[%d]"
,
i
);
}
}
a
,
b
=
mis
[
i
];
_
,
b
=
mis
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mis[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mis[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
msi
[
s
];
_
,
b
:=
msi
[
s
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: msi[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: msi[%d]"
,
i
);
}
}
a
,
b
=
msi
[
s
];
_
,
b
=
msi
[
s
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: msi[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: msi[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mss
[
s
];
_
,
b
:=
mss
[
s
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mss[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mss[%d]"
,
i
);
}
}
a
,
b
=
mss
[
s
];
_
,
b
=
mss
[
s
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mss[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mss[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mspa
[
s
];
_
,
b
:=
mspa
[
s
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mspa[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mspa[%d]"
,
i
);
}
}
a
,
b
=
mspa
[
s
];
_
,
b
=
mspa
[
s
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mspa[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mspa[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mipT
[
i
];
_
,
b
:=
mipT
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mipT[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mipT[%d]"
,
i
);
}
}
a
,
b
=
mipT
[
i
];
_
,
b
=
mipT
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mipT[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mipT[%d]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mpTi
[
apT
[
i
]];
_
,
b
:=
mpTi
[
apT
[
i
]];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mpTi[apt[%d]]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mpTi[apt[%d]]"
,
i
);
}
}
a
,
b
=
mpTi
[
apT
[
i
]];
_
,
b
=
mpTi
[
apT
[
i
]];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mpTi[apT[%d]]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mpTi[apT[%d]]"
,
i
);
}
}
}
}
{
{
a
,
b
:=
mipM
[
i
];
_
,
b
:=
mipM
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mipM[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mipM[%d]"
,
i
);
}
}
a
,
b
=
mipM
[
i
];
_
,
b
=
mipM
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mipM[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mipM[%d]"
,
i
);
}
}
}
}
// {
// {
//
a
, b := mti[t];
//
_
, b := mti[t];
// if b {
// if b {
// fmt.Printf("tuple nonexistence decl: mti[%d]", i);
// fmt.Printf("tuple nonexistence decl: mti[%d]", i);
// }
// }
//
a
, b = mti[t];
//
_
, b = mti[t];
// if b {
// if b {
// fmt.Printf("tuple nonexistence assign: mti[%d]", i);
// fmt.Printf("tuple nonexistence assign: mti[%d]", i);
// }
// }
// }
// }
{
{
a
,
b
:=
mit
[
i
];
_
,
b
:=
mit
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence decl: mit[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence decl: mit[%d]"
,
i
);
}
}
a
,
b
=
mit
[
i
];
_
,
b
=
mit
[
i
];
if
b
{
if
b
{
fmt
.
Printf
(
"tuple nonexistence assign: mit[%d]"
,
i
);
fmt
.
Printf
(
"tuple nonexistence assign: mit[%d]"
,
i
);
}
}
...
@@ -487,10 +484,10 @@ func main() {
...
@@ -487,10 +484,10 @@ func main() {
fmt
.
Printf
(
"update mipM[%d][%d] = %i
\n
"
,
i
,
i
,
mipM
[
i
][
i
]);
fmt
.
Printf
(
"update mipM[%d][%d] = %i
\n
"
,
i
,
i
,
mipM
[
i
][
i
]);
}
}
}
}
// test range on nil map
// test range on nil map
var
mnil
map
[
string
]
int
;
var
mnil
map
[
string
]
int
;
for
x
,
y
:
=
range
mnil
{
for
_
,
_
=
range
mnil
{
panic
(
"range mnil"
);
panic
(
"range mnil"
);
}
}
}
}
test/range.go
View file @
ae54cf73
...
@@ -42,7 +42,7 @@ func makearray() []int {
...
@@ -42,7 +42,7 @@ func makearray() []int {
func
testarray
()
{
func
testarray
()
{
s
:=
0
;
s
:=
0
;
for
k
,
v
:=
range
makearray
()
{
for
_
,
v
:=
range
makearray
()
{
s
+=
v
;
s
+=
v
;
}
}
if
nmake
!=
1
{
if
nmake
!=
1
{
...
...
usr/dsymonds/iterable/iterable_test.go
View file @
ae54cf73
...
@@ -13,7 +13,7 @@ type IntArray []int;
...
@@ -13,7 +13,7 @@ type IntArray []int;
func
(
arr
IntArray
)
Iter
()
<-
chan
interface
{}
{
func
(
arr
IntArray
)
Iter
()
<-
chan
interface
{}
{
ch
:=
make
(
chan
interface
{});
ch
:=
make
(
chan
interface
{});
go
func
()
{
go
func
()
{
for
i
,
x
:=
range
arr
{
for
_
,
x
:=
range
arr
{
ch
<-
x
ch
<-
x
}
}
close
(
ch
)
close
(
ch
)
...
...
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