]> Cypherpunks repositories - gostls13.git/commitdiff
test: add extra typeswitch tests that cause duplicate cases
authorDan Scales <danscales@google.com>
Tue, 7 Dec 2021 23:59:22 +0000 (15:59 -0800)
committerDan Scales <danscales@google.com>
Wed, 8 Dec 2021 17:55:13 +0000 (17:55 +0000)
Augmented some of the typeswitch*.go tests so that some instantiations
have duplicate cases, in order to ensure we're testing that.

Spacing changes in the tests are due to gofmt.

Change-Id: I5d3678813505c520c544281d4ac8a62ce7e236ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/370155
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
test/run.go
test/typeparam/typeswitch1.go
test/typeparam/typeswitch1.out
test/typeparam/typeswitch2.go
test/typeparam/typeswitch2.out
test/typeparam/typeswitch3.go
test/typeparam/typeswitch3.out
test/typeparam/typeswitch4.go
test/typeparam/typeswitch4.out

index 2ff7117ea9f975075c9c5e7738acb6302688b5ea..37be958959f97a355aeba804dd8cc0fd99131e1d 100644 (file)
@@ -2183,6 +2183,10 @@ var unifiedFailures = setOf(
        "fixedbugs/issue49767.go",  // unified IR doesn't report channel element too large
        "fixedbugs/issue49814.go",  // unified IR doesn't report array type too large
        "typeparam/issue50002.go",  // pure stenciling leads to a static type assertion error
+       "typeparam/typeswitch1.go", // duplicate case failure due to stenciling
+       "typeparam/typeswitch2.go", // duplicate case failure due to stenciling
+       "typeparam/typeswitch3.go", // duplicate case failure due to stenciling
+       "typeparam/typeswitch4.go", // duplicate case failure due to stenciling
 )
 
 func setOf(keys ...string) map[string]bool {
index 27161b3db8045a560698c89fae1155282c078c18..834302e37a1356194bee77b16759da231eeed059 100644 (file)
@@ -14,7 +14,7 @@ func f[T any](i interface{}) {
                println("int")
        case int32, int16:
                println("int32/int16")
-       case struct { a, b T }:
+       case struct{ a, b T }:
                println("struct{T,T}")
        default:
                println("other")
@@ -24,6 +24,8 @@ func main() {
        f[float64](float64(6))
        f[float64](int(7))
        f[float64](int32(8))
-       f[float64](struct{a, b float64}{a:1, b:2})
+       f[float64](struct{ a, b float64 }{a: 1, b: 2})
        f[float64](int8(9))
+       f[int32](int32(7))
+       f[int](int32(7))
 }
index 4bdbccfddb357ae52f65dfe4223be799a1b1eebe..dc5dfdb76116522636ea57997095cef06105f62b 100644 (file)
@@ -3,3 +3,5 @@ int
 int32/int16
 struct{T,T}
 other
+T
+int32/int16
index 0e434e1383adce5b5d3141edd1f33d6aabe6e4d4..ce4af34f04cefa5e20cc46c34c923eaa50c1f81d 100644 (file)
@@ -28,4 +28,6 @@ func main() {
        f[float64](int32(8))
        f[float64](struct{ a, b float64 }{a: 1, b: 2})
        f[float64](int8(9))
+       f[int32](int32(7))
+       f[int](int32(7))
 }
index 944cc04cc6e60946437637b7ab552439de18b506..85b54e38aebf60eb46cbba2f6a80fbf7adf0796a 100644 (file)
@@ -3,3 +3,5 @@ int 7
 int32/int16 8
 struct{T,T} +1.000000e+000 +2.000000e+000
 other 9
+T 7
+int32/int16 7
index 6ab030114095d6022a35d9f61a0801af597331c8..0527a83eb09f3340c515684805dd96b380c104ba 100644 (file)
@@ -6,16 +6,18 @@
 
 package main
 
-type I interface { foo() int }
+type I interface{ foo() int }
 
 type myint int
 
 func (x myint) foo() int { return int(x) }
 
 type myfloat float64
+
 func (x myfloat) foo() int { return int(x) }
 
 type myint32 int32
+
 func (x myint32) foo() int { return int(x) }
 
 func f[T I](i I) {
@@ -32,4 +34,7 @@ func main() {
        f[myfloat](myint(6))
        f[myfloat](myfloat(7))
        f[myfloat](myint32(8))
+       f[myint32](myint32(8))
+       f[myint32](myfloat(7))
+       f[myint](myint32(9))
 }
index 2c69c72c300f6e7163d3bd12367eb001ca61d337..ed59987e6d96deb29b29e0463cc4fd8ce8a67879 100644 (file)
@@ -1,3 +1,6 @@
 myint 6
 T 7
 other 8
+T 8
+other 7
+other 9
index 6113026b65823bfd541eae70f1f9e31a0d9c5cd2..08de2a1d411a4245936a2c0577433571f66d28df 100644 (file)
@@ -6,16 +6,18 @@
 
 package main
 
-type I interface { foo() int }
+type I interface{ foo() int }
 
 type myint int
 
-func (x myint) foo() int {return int(x)}
+func (x myint) foo() int { return int(x) }
 
 type myfloat float64
-func (x myfloat) foo() int {return int(x)}
+
+func (x myfloat) foo() int { return int(x) }
 
 type myint32 int32
+
 func (x myint32) foo() int { return int(x) }
 
 func f[T I](i I) {
@@ -30,4 +32,7 @@ func main() {
        f[myfloat](myint(6))
        f[myfloat](myfloat(7))
        f[myfloat](myint32(8))
+       f[myint32](myint32(9))
+       f[myint](myint32(10))
+       f[myint](myfloat(42))
 }
index b0d54077c926104cac85a5c1bc0bec496f0cba9d..d6121d077c051976f0a6bea207e9f41b5fb8eda8 100644 (file)
@@ -1,3 +1,6 @@
 other 6
 T/myint32 7
 T/myint32 8
+T/myint32 9
+T/myint32 10
+other 42