mirror of
https://github.com/golang/go
synced 2024-09-15 22:20:06 +00:00
95e85e3108
Type constraint satisfaction is interface implementation. Adjusted a few error messages. Change-Id: I4266af78e83131a76b1e3e44c847a21de760ac6e Reviewed-on: https://go-review.googlesource.com/c/go/+/363839 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
39 lines
927 B
Go
39 lines
927 B
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() {
|
|
const want = 2
|
|
if got := a.Min[int](2, 3); got != want {
|
|
panic(fmt.Sprintf("got %d, want %d", got, want))
|
|
}
|
|
|
|
if got := a.Min(2, 3); got != want {
|
|
panic(fmt.Sprintf("want %d, got %d", want, got))
|
|
}
|
|
|
|
if got := a.Min[float64](3.5, 2.0); got != want {
|
|
panic(fmt.Sprintf("got %d, want %d", got, want))
|
|
}
|
|
|
|
if got := a.Min(3.5, 2.0); got != want {
|
|
panic(fmt.Sprintf("got %d, want %d", got, want))
|
|
}
|
|
|
|
const want2 = "ay"
|
|
if got := a.Min[string]("bb", "ay"); got != want2 { // ERROR "string does not implement"
|
|
panic(fmt.Sprintf("got %d, want %d", got, want2))
|
|
}
|
|
|
|
if got := a.Min("bb", "ay"); got != want2 { // ERROR "string does not implement"
|
|
panic(fmt.Sprintf("got %d, want %d", got, want2))
|
|
}
|
|
}
|