Skip to content

Commit

Permalink
Rename Wildcard to MatchAll
Browse files Browse the repository at this point in the history
  • Loading branch information
tangrufus committed Dec 6, 2024
1 parent 89233c1 commit 2ccdd7b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func Compact(o Or) Constrainter { //nolint:cyclop,ireturn
ceiling, ceilingOk := maxFloorlessCeiling(o...)
floor, floorOk := minCeilinglessFloor(o...)

// short circuit if we have a orToMatchAll
if ceilingOk && floorOk && orToMatchAll(ceiling, floor) {
// short circuit if we have a match all
if ceilingOk && floorOk && disjunctivelyCombineToMatchAll(ceiling, floor) {
return NewMatchAll()
}

Expand Down Expand Up @@ -87,7 +87,7 @@ func minCeilinglessFloor(cs ...CeilingFloorConstrainter) (Endless, bool) {

for i := range o {
if o[i].floor().compare(m) < 0 {
if o[i].Check(*m.version) || orToMatchAll(o[i].ceiling(), m) {
if o[i].Check(*m.version) || disjunctivelyCombineToMatchAll(o[i].ceiling(), m) {
m = o[i].floor()
}

Expand Down Expand Up @@ -130,7 +130,7 @@ func maxFloorlessCeiling(cs ...CeilingFloorConstrainter) (Endless, bool) {

for i := range o {
if o[i].ceiling().compare(m) > 0 {
if o[i].Check(*m.version) || orToMatchAll(o[i].floor(), m) {
if o[i].Check(*m.version) || disjunctivelyCombineToMatchAll(o[i].floor(), m) {
m = o[i].ceiling()
}

Expand All @@ -149,7 +149,7 @@ func maxFloorlessCeiling(cs ...CeilingFloorConstrainter) (Endless, bool) {
return m, true
}

func orToMatchAll(e, f Endless) bool {
func disjunctivelyCombineToMatchAll(e, f Endless) bool {
if e.ceilingBounded() && f.ceilingBounded() {
return false
}
Expand Down
2 changes: 1 addition & 1 deletion compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ func Test_matchAll(t *testing.T) {
t.Parallel()

if got := matchAll(tt.c); got != tt.want {
t.Errorf("orToMatchAll() = %v, want %v", got, tt.want)
t.Errorf("disjunctivelyCombineToMatchAll() = %v, want %v", got, tt.want)
}
})
}
Expand Down
6 changes: 3 additions & 3 deletions endless.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package comver

// Endless represents a constraint that is either floor bounded, ceiling bounded,
// or orToMatchAll (satisfied by any version).
// The zero value for Endless is a orToMatchAll constraint (satisfied by any version).
// or disjunctivelyCombineToMatchAll (satisfied by any version).
// The zero value for Endless is a disjunctivelyCombineToMatchAll constraint (satisfied by any version).
type Endless struct {
// The version used in the constraint check,
// e.g.: the version representing 1.2.3 in '<=1.2.3'.
Expand Down Expand Up @@ -48,7 +48,7 @@ func NewMatchAll() Endless {
// Check reports whether a [Version] satisfies the constraint.
func (b Endless) Check(v Version) bool {
if b.version == nil {
// this is orToMatchAll, match all versions
// this is disjunctivelyCombineToMatchAll, match all versions
return true
}

Expand Down
10 changes: 5 additions & 5 deletions endless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestEndless_Check(t *testing.T) {
want: false,
},
{
name: "orToMatchAll",
name: "disjunctivelyCombineToMatchAll",
endless: NewMatchAll(),
version: MustParse("1"),
want: true,
Expand Down Expand Up @@ -161,7 +161,7 @@ func TestEndless_Ceiling(t *testing.T) {
want: NewMatchAll(),
},
{
name: "orToMatchAll",
name: "disjunctivelyCombineToMatchAll",
endless: NewMatchAll(),
want: NewMatchAll(),
},
Expand Down Expand Up @@ -207,7 +207,7 @@ func TestEndless_Floor(t *testing.T) {
want: NewGreaterThan(MustParse("4")),
},
{
name: "orToMatchAll",
name: "disjunctivelyCombineToMatchAll",
endless: NewMatchAll(),
want: NewMatchAll(),
},
Expand Down Expand Up @@ -253,7 +253,7 @@ func TestEndless_matchAll(t *testing.T) {
want: false,
},
{
name: "orToMatchAll",
name: "disjunctivelyCombineToMatchAll",
endless: NewMatchAll(),
want: true,
},
Expand All @@ -263,7 +263,7 @@ func TestEndless_matchAll(t *testing.T) {
t.Parallel()

if got := tt.endless.matchAll(); got != tt.want {
t.Errorf("orToMatchAll() = %v, want %v", got, tt.want)
t.Errorf("disjunctivelyCombineToMatchAll() = %v, want %v", got, tt.want)
}
})
}
Expand Down

0 comments on commit 2ccdd7b

Please sign in to comment.