diff options
author | Ken Thompson <ken@golang.org> | 2009-03-18 12:13:42 -0700 |
---|---|---|
committer | Ken Thompson <ken@golang.org> | 2009-03-18 12:13:42 -0700 |
commit | 15c8574393a47c5aeec17b9e3a2fb8db9cfed1e7 (patch) | |
tree | b2083bee714faab6ace8bc245b426d1195218d01 /test/typeswitch.go | |
parent | 44d17609498a0eb399f8c08f775bfd3afe7d25d4 (diff) | |
download | go-15c8574393a47c5aeec17b9e3a2fb8db9cfed1e7.tar.gz |
remove assignment cases from switch
R=r
OCL=26480
CL=26480
Diffstat (limited to 'test/typeswitch.go')
-rw-r--r-- | test/typeswitch.go | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/test/typeswitch.go b/test/typeswitch.go index a28806d5c..ed899e098 100644 --- a/test/typeswitch.go +++ b/test/typeswitch.go @@ -62,30 +62,30 @@ func f(i int) interface{} { func main() { // type guard style - for i := Bool; i < Last; i++ { - switch v := f(i); true { - case x := v.(bool): - assert(x == true && i == Bool, "switch 1 bool"); - case x := v.(int): - assert(x == 7 && i == Int, "switch 1 int"); - case x := v.(float): - assert(x == 7.4 && i == Float, "switch 1 float"); - case x := v.(string): - assert(x == "hello" && i == String, "switch 1 string"); - case x := v.(S): - assert(x.a == 1234 && i == Struct, "switch 1 struct"); - case x := v.(chan int): - assert(x == c && i == Chan, "switch 1 chan"); - case x := v.([]int): - assert(x[3] == 3 && i == Array, "switch 1 array"); - case x := v.(map[string]int): - assert(x == m && i == Map, "switch 1 map"); - case x := v.(func(i int) interface{}): - assert(x == f && i == Func, "switch 1 fun"); - default: - assert(false, "switch 1 unknown"); - } - } +// for i := Bool; i < Last; i++ { +// switch v := f(i); true { +// case x := v.(bool): +// assert(x == true && i == Bool, "switch 1 bool"); +// case x := v.(int): +// assert(x == 7 && i == Int, "switch 1 int"); +// case x := v.(float): +// assert(x == 7.4 && i == Float, "switch 1 float"); +// case x := v.(string): +// assert(x == "hello" && i == String, "switch 1 string"); +// case x := v.(S): +// assert(x.a == 1234 && i == Struct, "switch 1 struct"); +// case x := v.(chan int): +// assert(x == c && i == Chan, "switch 1 chan"); +// case x := v.([]int): +// assert(x[3] == 3 && i == Array, "switch 1 array"); +// case x := v.(map[string]int): +// assert(x == m && i == Map, "switch 1 map"); +// case x := v.(func(i int) interface{}): +// assert(x == f && i == Func, "switch 1 fun"); +// default: +// assert(false, "switch 1 unknown"); +// } +// } // type switch style for i := Bool; i < Last; i++ { @@ -135,24 +135,24 @@ func main() { assert(false, "switch 4 unknown"); } - switch true { - case x := f(Int).(float): - assert(false, "switch 5 type guard wrong type"); - case x := f(Int).(int): - assert(x == 7, "switch 5 type guard"); - default: - assert(false, "switch 5 unknown"); - } +// switch true { +// case x := f(Int).(float): +// assert(false, "switch 5 type guard wrong type"); +// case x := f(Int).(int): +// assert(x == 7, "switch 5 type guard"); +// default: +// assert(false, "switch 5 unknown"); +// } m["7"] = 7; - switch true { - case x := m["6"]: - assert(false, "switch 6 map reference wrong"); - case x := m["7"]: - assert(x == 7, "switch 6 map reference"); - default: - assert(false, "switch 6 unknown"); - } +// switch true { +// case x := m["6"]: +// assert(false, "switch 6 map reference wrong"); +// case x := m["7"]: +// assert(x == 7, "switch 6 map reference"); +// default: +// assert(false, "switch 6 unknown"); +// } go func() { <-c; c <- 77; } (); // guarantee the channel is ready @@ -161,13 +161,13 @@ func main() { sys.Gosched(); } dummyc := make(chan int); - switch true { - case x := <-dummyc: - assert(false, "switch 7 chan wrong"); - case x := <-c: - assert(x == 77, "switch 7 chan"); - default: - assert(false, "switch 7 unknown"); - } +// switch true { +// case x := <-dummyc: +// assert(false, "switch 7 chan wrong"); +// case x := <-c: +// assert(x == 77, "switch 7 chan"); +// default: +// assert(false, "switch 7 unknown"); +// } } |