mirror of
https://github.com/golang/go
synced 2024-09-18 15:32:18 +00:00
ccbfbb1c33
Added new test typeparam/factimp.go and changed a bunch of other tests to test exporting more generic functions and types. Change-Id: I573d75431cc92482f8f908695cfbc8e84dbb36d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/321749 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
// Copyright 2021 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package main
|
|
|
|
import (
|
|
"a"
|
|
"fmt"
|
|
)
|
|
|
|
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))
|
|
}
|
|
|
|
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))
|
|
}
|
|
|
|
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))
|
|
}
|
|
}
|