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
bd3c478f
Commit
bd3c478f
authored
Mar 18, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add value checks to the other switch - should have done this in prior round
R=rsc OCL=26438 CL=26438
parent
bcb464d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
typeswitch.go
test/typeswitch.go
+9
-9
No files found.
test/typeswitch.go
View file @
bd3c478f
...
...
@@ -91,23 +91,23 @@ func main() {
for
i
:=
Bool
;
i
<
Last
;
i
++
{
switch
x
:=
f
(
i
)
.
(
type
)
{
case
bool
:
assert
(
x
==
true
,
"switch 2 bool"
);
assert
(
x
==
true
&&
i
==
Bool
,
"switch 2 bool"
);
case
int
:
assert
(
x
==
7
,
"switch 2 int"
);
assert
(
x
==
7
&&
i
==
Int
,
"switch 2 int"
);
case
float
:
assert
(
x
==
7.4
,
"switch 2 float"
);
assert
(
x
==
7.4
&&
i
==
Float
,
"switch 2 float"
);
case
string
:
assert
(
x
==
"hello"
,
"switch 2 string"
);
assert
(
x
==
"hello"
&&
i
==
String
,
"switch 2 string"
);
case
S
:
assert
(
x
.
a
==
1234
,
"switch 2 struct"
);
assert
(
x
.
a
==
1234
&&
i
==
Struct
,
"switch 2 struct"
);
case
chan
int
:
assert
(
x
==
c
,
"switch 2 chan"
);
assert
(
x
==
c
&&
i
==
Chan
,
"switch 2 chan"
);
case
[]
int
:
assert
(
x
[
3
]
==
3
,
"switch 2 array"
);
assert
(
x
[
3
]
==
3
&&
i
==
Array
,
"switch 2 array"
);
case
map
[
string
]
int
:
assert
(
x
==
m
,
"switch 2 map"
);
assert
(
x
==
m
&&
i
==
Map
,
"switch 2 map"
);
case
func
(
i
int
)
interface
{}
:
assert
(
x
==
f
,
"switch 2 fun"
);
assert
(
x
==
f
&&
i
==
Func
,
"switch 2 fun"
);
default
:
assert
(
false
,
"switch 2 unknown"
);
}
...
...
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