aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam/dictionaryCapture.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-07-28 13:39:30 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-07-28 21:40:40 +0000
commit53557530093938e19c21f6b02a482939ac6e634b (patch)
tree18d51aa04629aaad621399e997306118b36a5952 /test/typeparam/dictionaryCapture.go
parent473e493d18c277d69e40a4930af045d474ff2be4 (diff)
downloadgo-53557530093938e19c21f6b02a482939ac6e634b.tar.gz
go-53557530093938e19c21f6b02a482939ac6e634b.zip
[dev.typeparams] test/typeparam: gofmt -w
We don't usually reformat the test directory, but all of the files in test/typeparam are syntactically valid. I suspect the misformattings here are because developers aren't re-installing gofmt with -tags=typeparams, not intentionally exercising non-standard formatting. Change-Id: I3767d480434c19225568f3c7d656dc8589197183 Reviewed-on: https://go-review.googlesource.com/c/go/+/338093 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'test/typeparam/dictionaryCapture.go')
-rw-r--r--test/typeparam/dictionaryCapture.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/test/typeparam/dictionaryCapture.go b/test/typeparam/dictionaryCapture.go
index 26af7a09b0..7c7948145a 100644
--- a/test/typeparam/dictionaryCapture.go
+++ b/test/typeparam/dictionaryCapture.go
@@ -51,7 +51,7 @@ func is7(x int) {
}
func is77(x, y int) {
if x != 7 || y != 7 {
- println(x,y)
+ println(x, y)
panic("assertion failed")
}
}
@@ -70,7 +70,7 @@ func (x s[T]) g2() (T, T) {
}
func methodExpressions() {
- x := s[int]{a:7}
+ x := s[int]{a: 7}
f0 := s[int].g0
f0(x)
f0p := (*s[int]).g0
@@ -106,7 +106,7 @@ func genMethodExpressions[T comparable](want T) {
}
func methodValues() {
- x := s[int]{a:7}
+ x := s[int]{a: 7}
f0 := x.g0
f0()
f1 := x.g1
@@ -129,20 +129,20 @@ func genMethodValues[T comparable](want T) {
}
}
-var x interface{
+var x interface {
g0()
- g1()int
- g2()(int,int)
-} = s[int]{a:7}
-var y interface{} = s[int]{a:7}
+ g1() int
+ g2() (int, int)
+} = s[int]{a: 7}
+var y interface{} = s[int]{a: 7}
func interfaceMethods() {
x.g0()
is7(x.g1())
is77(x.g2())
- y.(interface{g0()}).g0()
- is7(y.(interface{g1()int}).g1())
- is77(y.(interface{g2()(int,int)}).g2())
+ y.(interface{ g0() }).g0()
+ is7(y.(interface{ g1() int }).g1())
+ is77(y.(interface{ g2() (int, int) }).g2())
}
// Also check for instantiations outside functions.
@@ -154,7 +154,7 @@ var hh0 = s[int].g0
var hh1 = s[int].g1
var hh2 = s[int].g2
-var xtop = s[int]{a:7}
+var xtop = s[int]{a: 7}
var ii0 = x.g0
var ii1 = x.g1
var ii2 = x.g2
@@ -163,7 +163,7 @@ func globals() {
gg0(7)
is7(gg1(7))
is77(gg2(7))
- x := s[int]{a:7}
+ x := s[int]{a: 7}
hh0(x)
is7(hh1(x))
is77(hh2(x))
@@ -172,7 +172,6 @@ func globals() {
is77(ii2())
}
-
func recursive() {
if got, want := recur1[int](5), 110; got != want {
panic(fmt.Sprintf("recur1[int](5) = %d, want = %d", got, want))
@@ -187,14 +186,14 @@ func recur1[T Integer](n T) T {
if n == 0 || n == 1 {
return T(1)
} else {
- return n * recur2(n - 1)
+ return n * recur2(n-1)
}
}
func recur2[T Integer](n T) T {
list := make([]T, n)
for i, _ := range list {
- list[i] = T(i+1)
+ list[i] = T(i + 1)
}
var sum T
for _, elt := range list {