Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
  • Loading branch information
MadhavJivrajani committed Jan 16, 2024
1 parent 9f67429 commit 12fe39a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# dummy comment
.PHONY: verify
verify: verify-fmt verify-lint verify-apidiff vet test

Expand Down
2 changes: 1 addition & 1 deletion set/ordered.go
Expand Up @@ -20,7 +20,7 @@ package set
// that supports the operators < <= >= >.
// If future releases of Go add new ordered types,
// this constraint will be modified to include them.
type ordered interface {
type orderedBrokenAPI interface {
integer | float | ~string
}

Expand Down
10 changes: 5 additions & 5 deletions set/set.go
Expand Up @@ -25,17 +25,17 @@ import (
type Empty struct{}

// Set is a set of the same type elements, implemented via map[ordered]struct{} for minimal memory consumption.
type Set[E ordered] map[E]Empty
type Set[E orderedBrokenAPI] map[E]Empty

// New creates a new set.
func New[E ordered](items ...E) Set[E] {
func New[E orderedBrokenAPI](items ...E) Set[E] {
ss := Set[E]{}
ss.Insert(items...)
return ss
}

// KeySet creates a Set[E] from a keys of a map[E](? extends interface{}).
func KeySet[E ordered, A any](theMap map[E]A) Set[E] {
func KeySet[E orderedBrokenAPI, A any](theMap map[E]A) Set[E] {
ret := Set[E]{}
for key := range theMap {
ret.Insert(key)
Expand Down Expand Up @@ -158,7 +158,7 @@ func (s Set[E]) Equal(s2 Set[E]) bool {
return s.Len() == s.Len() && s.IsSuperset(s2)
}

type sortableSlice[E ordered] []E
type sortableSlice[E orderedBrokenAPI] []E

func (s sortableSlice[E]) Len() int {
return len(s)
Expand All @@ -168,7 +168,7 @@ func (s sortableSlice[E]) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

// SortedList returns the contents as a sorted slice.
func (s Set[E]) SortedList() []E {
res := make(sortableSlice[E], 0, s.Len())
res = make(sortableSlice[E], 0, s.Len())

Check failure on line 171 in set/set.go

View workflow job for this annotation

GitHub Actions / lint

undefined: res

Check failure on line 171 in set/set.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: res

Check failure on line 171 in set/set.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: res

Check failure on line 171 in set/set.go

View workflow job for this annotation

GitHub Actions / build (1.21.x, windows-latest)

undefined: res

Check failure on line 171 in set/set.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

undefined: res
for key := range s {
res = append(res, key)

Check failure on line 173 in set/set.go

View workflow job for this annotation

GitHub Actions / lint

undefined: res

Check failure on line 173 in set/set.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

undefined: res

Check failure on line 173 in set/set.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, macos-latest)

undefined: res

Check failure on line 173 in set/set.go

View workflow job for this annotation

GitHub Actions / build (1.21.x, windows-latest)

undefined: res

Check failure on line 173 in set/set.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, ubuntu-latest)

undefined: res
}
Expand Down
2 changes: 1 addition & 1 deletion set/set_test.go
Expand Up @@ -359,7 +359,7 @@ func TestSetClearInSeparateFunction(t *testing.T) {
}
}

func clearSetAndAdd[T ordered](s Set[T], a T) {
func clearSetAndAdd[T orderedBrokenAPI](s Set[T], a T) {
s.Clear()
s.Insert(a)
}

0 comments on commit 12fe39a

Please sign in to comment.