cmd/go2go: rename testdata contracts to constraints

Change-Id: I52eaf2e87abc53b79b2fbcfcb156f093298341ef
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/750508
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
Ian Lance Taylor 2020-05-18 16:23:41 -07:00 committed by Robert Griesemer
parent db04e7cb2e
commit 4b7067c133
7 changed files with 17 additions and 17 deletions

View File

@ -5,10 +5,10 @@
// Package alg provides basic algorithms.
package alg
import "contracts"
import "constraints"
// Max returns the maximum of two values of some ordered type.
func Max(type T contracts.Ordered)(a, b T) T {
func Max(type T constraints.Ordered)(a, b T) T {
if a < b {
return b
}
@ -16,7 +16,7 @@ func Max(type T contracts.Ordered)(a, b T) T {
}
// Min returns the minimum of two values of some ordered type.
func Min(type T contracts.Ordered)(a, b T) T {
func Min(type T constraints.Ordered)(a, b T) T {
if a < b {
return a
}

View File

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package contracts defines some useful type bounds.
package contracts
// Package constraints defines some useful type constraints.
package constraints
// Ordered permits any ordered type: any type that supports
// the operations <, <=, >=, >, as well as == and !=.

View File

@ -8,11 +8,11 @@ package gsort
import (
"sort"
"contracts"
"constraints"
)
// orderedSlice is a slice of values of some ordered type.
type orderedSlice(type Elem contracts.Ordered) []Elem
type orderedSlice(type Elem constraints.Ordered) []Elem
// orderedSlice implements sort.Interface.
@ -30,7 +30,7 @@ func (s orderedSlice(Elem)) Less(i, j int) bool {
func (s orderedSlice(Elem)) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// OrderedSlice sorts a slice of any ordered type in ascending order.
func OrderedSlice(type Elem contracts.Ordered)(s []Elem) {
func OrderedSlice(type Elem constraints.Ordered)(s []Elem) {
sort.Sort(orderedSlice(Elem)(s))
}

View File

@ -9,7 +9,7 @@ import (
"sort"
"testing"
"contracts"
"constraints"
"slices"
)
@ -31,7 +31,7 @@ func TestSortOrderedStrings(t *testing.T) {
testOrdered(t, strs, sort.Strings)
}
func testOrdered(type Elem contracts.Ordered)(t *testing.T, s []Elem, sorter func([]Elem)) {
func testOrdered(type Elem constraints.Ordered)(t *testing.T, s []Elem, sorter func([]Elem)) {
s1 := make([]Elem, len(s))
copy(s1, s)
s2 := make([]Elem, len(s))

View File

@ -11,7 +11,7 @@ import (
"context"
"chans"
"contracts"
"constraints"
)
// Map is an ordered map.
@ -37,7 +37,7 @@ func New(type K, V)(compare func(K, K) int) *Map(K, V) {
// NewOrdered returns a new map whose key is an ordered type.
// This is like New, but does not require providing a compare function.
// The map compare function uses the obvious key ordering.
func NewOrdered(type K contracts.Ordered, V interface{})() *Map(K, V) {
func NewOrdered(type K constraints.Ordered, V interface{})() *Map(K, V) {
return New(K, V)(func(k1, k2 K) int {
switch {
case k1 < k2:

View File

@ -8,7 +8,7 @@ package slices
import (
"alg"
"contracts"
"constraints"
)
// Equal reports whether two slices are equal: the same length and all
@ -76,7 +76,7 @@ func Filter(type Elem)(s []Elem, f func(Elem) bool) []Elem {
// Max returns the maximum element in a slice of some ordered type.
// If the slice is empty it returns the zero value of the element type.
func Max(type Elem contracts.Ordered)(s []Elem) Elem {
func Max(type Elem constraints.Ordered)(s []Elem) Elem {
if len(s) == 0 {
var zero Elem
return zero
@ -86,7 +86,7 @@ func Max(type Elem contracts.Ordered)(s []Elem) Elem {
// Min returns the minimum element in a slice of some ordered type.
// If the slice is empty it returns the zero value of the element type.
func Min(type Elem contracts.Ordered)(s []Elem) Elem {
func Min(type Elem constraints.Ordered)(s []Elem) Elem {
if len(s) == 0 {
var zero Elem
return zero

View File

@ -9,7 +9,7 @@ import (
"strings"
"testing"
"contracts"
"constraints"
)
func TestEqual(t *testing.T) {
@ -42,7 +42,7 @@ func TestEqual(t *testing.T) {
}
}
func offByOne(type Elem contracts.Integer)(a, b Elem) bool {
func offByOne(type Elem constraints.Integer)(a, b Elem) bool {
return a == b + 1 || a == b - 1
}