diff options
author | Matthew Dempsky <mdempsky@google.com> | 2021-07-28 13:39:30 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2021-07-28 21:40:40 +0000 |
commit | 53557530093938e19c21f6b02a482939ac6e634b (patch) | |
tree | 18d51aa04629aaad621399e997306118b36a5952 /test/typeparam/listimp.dir | |
parent | 473e493d18c277d69e40a4930af045d474ff2be4 (diff) | |
download | go-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/listimp.dir')
-rw-r--r-- | test/typeparam/listimp.dir/a.go | 50 | ||||
-rw-r--r-- | test/typeparam/listimp.dir/main.go | 72 |
2 files changed, 61 insertions, 61 deletions
diff --git a/test/typeparam/listimp.dir/a.go b/test/typeparam/listimp.dir/a.go index 2b5b23cde3..bf1641af9c 100644 --- a/test/typeparam/listimp.dir/a.go +++ b/test/typeparam/listimp.dir/a.go @@ -5,49 +5,49 @@ package a type Ordered interface { - ~int | ~int8 | ~int16 | ~int32 | ~int64 | - ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | - ~float32 | ~float64 | - ~string + ~int | ~int8 | ~int16 | ~int32 | ~int64 | + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | + ~float32 | ~float64 | + ~string } // List is a linked list of ordered values of type T. type List[T Ordered] struct { - Next *List[T] - Val T + Next *List[T] + Val T } func (l *List[T]) Largest() T { - var max T - for p := l; p != nil; p = p.Next { - if p.Val > max { - max = p.Val - } - } - return max + var max T + for p := l; p != nil; p = p.Next { + if p.Val > max { + max = p.Val + } + } + return max } type OrderedNum interface { - ~int | ~int8 | ~int16 | ~int32 | ~int64 | - ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | - ~float32 | ~float64 + ~int | ~int8 | ~int16 | ~int32 | ~int64 | + ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | + ~float32 | ~float64 } // ListNum is a linked _List of ordered numeric values of type T. type ListNum[T OrderedNum] struct { - Next *ListNum[T] - Val T + Next *ListNum[T] + Val T } const Clip = 5 // clippedLargest returns the largest in the list of OrderNums, but a max of 5. func (l *ListNum[T]) ClippedLargest() T { - var max T - for p := l; p != nil; p = p.Next { - if p.Val > max && p.Val < Clip { - max = p.Val - } - } - return max + var max T + for p := l; p != nil; p = p.Next { + if p.Val > max && p.Val < Clip { + max = p.Val + } + } + return max } diff --git a/test/typeparam/listimp.dir/main.go b/test/typeparam/listimp.dir/main.go index d43ad508be..985ff59a18 100644 --- a/test/typeparam/listimp.dir/main.go +++ b/test/typeparam/listimp.dir/main.go @@ -10,43 +10,43 @@ import ( ) func main() { - i3 := &a.List[int]{nil, 1} - i2 := &a.List[int]{i3, 3} - i1 := &a.List[int]{i2, 2} - if got, want := i1.Largest(), 3; got != want { - panic(fmt.Sprintf("got %d, want %d", got, want)) - } + i3 := &a.List[int]{nil, 1} + i2 := &a.List[int]{i3, 3} + i1 := &a.List[int]{i2, 2} + if got, want := i1.Largest(), 3; got != want { + panic(fmt.Sprintf("got %d, want %d", got, want)) + } - b3 := &a.List[byte]{nil, byte(1)} - b2 := &a.List[byte]{b3, byte(3)} - b1 := &a.List[byte]{b2, byte(2)} - if got, want := b1.Largest(), byte(3); got != want { - panic(fmt.Sprintf("got %d, want %d", got, want)) - } + b3 := &a.List[byte]{nil, byte(1)} + b2 := &a.List[byte]{b3, byte(3)} + b1 := &a.List[byte]{b2, byte(2)} + if got, want := b1.Largest(), byte(3); got != want { + panic(fmt.Sprintf("got %d, want %d", got, want)) + } - f3 := &a.List[float64]{nil, 13.5} - f2 := &a.List[float64]{f3, 1.2} - f1 := &a.List[float64]{f2, 4.5} - if got, want := f1.Largest(), 13.5; got != want { - panic(fmt.Sprintf("got %f, want %f", got, want)) - } + f3 := &a.List[float64]{nil, 13.5} + f2 := &a.List[float64]{f3, 1.2} + f1 := &a.List[float64]{f2, 4.5} + if got, want := f1.Largest(), 13.5; got != want { + panic(fmt.Sprintf("got %f, want %f", got, want)) + } - s3 := &a.List[string]{nil, "dd"} - s2 := &a.List[string]{s3, "aa"} - s1 := &a.List[string]{s2, "bb"} - if got, want := s1.Largest(), "dd"; got != want { - panic(fmt.Sprintf("got %s, want %s", got, want)) - } - j3 := &a.ListNum[int]{nil, 1} - j2 := &a.ListNum[int]{j3, 32} - j1 := &a.ListNum[int]{j2, 2} - if got, want := j1.ClippedLargest(), 2; got != want { - panic(fmt.Sprintf("got %d, want %d", got, want)) - } - g3 := &a.ListNum[float64]{nil, 13.5} - g2 := &a.ListNum[float64]{g3, 1.2} - g1 := &a.ListNum[float64]{g2, 4.5} - if got, want := g1.ClippedLargest(), 4.5; got != want { - panic(fmt.Sprintf("got %f, want %f", got, want)) - } + s3 := &a.List[string]{nil, "dd"} + s2 := &a.List[string]{s3, "aa"} + s1 := &a.List[string]{s2, "bb"} + if got, want := s1.Largest(), "dd"; got != want { + panic(fmt.Sprintf("got %s, want %s", got, want)) + } + j3 := &a.ListNum[int]{nil, 1} + j2 := &a.ListNum[int]{j3, 32} + j1 := &a.ListNum[int]{j2, 2} + if got, want := j1.ClippedLargest(), 2; got != want { + panic(fmt.Sprintf("got %d, want %d", got, want)) + } + g3 := &a.ListNum[float64]{nil, 13.5} + g2 := &a.ListNum[float64]{g3, 1.2} + g1 := &a.ListNum[float64]{g2, 4.5} + if got, want := g1.ClippedLargest(), 4.5; got != want { + panic(fmt.Sprintf("got %f, want %f", got, want)) + } } |