diff --git a/and.go b/and.go index 64803a0..af82ba4 100644 --- a/and.go +++ b/and.go @@ -19,10 +19,10 @@ func And(es ...Endless) (CeilingFloorConstrainter, error) { //nolint:cyclop,iret } es = slices.Clone(es) - es = slices.DeleteFunc(es, Endless.wildcard) + es = slices.DeleteFunc(es, Endless.matchAll) if len(es) == 0 { - return NewWildcard(), nil + return NewMatchAll(), nil } if len(es) == 1 { return es[0], nil @@ -94,7 +94,7 @@ func maxBoundedFloor(es ...Endless) (Endless, bool) { es = slices.Clone(es) bfs := slices.DeleteFunc(es, func(c Endless) bool { - return c.floor().wildcard() + return c.floor().matchAll() }) if len(bfs) == 0 { diff --git a/and_example_test.go b/and_example_test.go index 956a14e..6f219e5 100644 --- a/and_example_test.go +++ b/and_example_test.go @@ -16,11 +16,11 @@ func ExampleAnd() { // Output: >=2 <3 } -func ExampleAnd_wildcard() { +func ExampleAnd_matchAll() { a, _ := comver.And( comver.NewGreaterThanOrEqualTo(comver.MustParse("2")), comver.NewLessThan(comver.MustParse("3")), - comver.NewWildcard(), + comver.NewMatchAll(), ) fmt.Println(a) diff --git a/and_test.go b/and_test.go index 2347de2..4785ac1 100644 --- a/and_test.go +++ b/and_test.go @@ -50,15 +50,15 @@ func TestAnd(t *testing.T) { wantErr: nil, }, { - name: "single_wildcard", - es: []Endless{NewWildcard()}, - want: NewWildcard(), + name: "single_match_all", + es: []Endless{NewMatchAll()}, + want: NewMatchAll(), wantErr: nil, }, { - name: "multiple_wildcards", - es: []Endless{NewWildcard(), NewWildcard()}, - want: NewWildcard(), + name: "multiple_match_alls", + es: []Endless{NewMatchAll(), NewMatchAll()}, + want: NewMatchAll(), wantErr: nil, }, { @@ -114,17 +114,17 @@ func TestAnd(t *testing.T) { wantErr: errImpossibleInterval, }, { - name: "impossible_interval_wildcard", + name: "impossible_interval_match_all", es: []Endless{ NewLessThan(MustParse("1")), NewGreaterThan(MustParse("4")), - NewWildcard(), + NewMatchAll(), }, want: nilC, wantErr: errImpossibleInterval, }, { - name: "multiple_wildcards_multiple_endlesses", + name: "multiple_match_alls_multiple_endlesses", es: []Endless{ NewLessThan(MustParse("1")), NewLessThanOrEqualTo(MustParse("1")), @@ -134,8 +134,8 @@ func TestAnd(t *testing.T) { NewGreaterThan(MustParse("3")), NewGreaterThanOrEqualTo(MustParse("4")), NewGreaterThan(MustParse("4")), - NewWildcard(), - NewWildcard(), + NewMatchAll(), + NewMatchAll(), }, want: nilC, wantErr: errImpossibleInterval, @@ -178,11 +178,11 @@ func TestAnd(t *testing.T) { wantErr: nil, }, { - name: "exact_version_wildcard", + name: "exact_version_match_all", es: []Endless{ NewLessThanOrEqualTo(MustParse("1")), NewGreaterThanOrEqualTo(MustParse("1")), - NewWildcard(), + NewMatchAll(), }, want: NewExactConstraint(MustParse("1")), wantErr: nil, @@ -198,8 +198,8 @@ func TestAnd(t *testing.T) { NewGreaterThanOrEqualTo(MustParse("1")), NewGreaterThan(MustParse("1")), NewGreaterThan(MustParse("1")), - NewWildcard(), - NewWildcard(), + NewMatchAll(), + NewMatchAll(), }, want: nilC, wantErr: errImpossibleInterval, @@ -213,8 +213,8 @@ func TestAnd(t *testing.T) { NewGreaterThanOrEqualTo(MustParse("1")), NewGreaterThan(MustParse("1")), NewGreaterThan(MustParse("1")), - NewWildcard(), - NewWildcard(), + NewMatchAll(), + NewMatchAll(), }, want: nilC, wantErr: errImpossibleInterval, @@ -226,8 +226,8 @@ func TestAnd(t *testing.T) { NewLessThanOrEqualTo(MustParse("1")), NewGreaterThanOrEqualTo(MustParse("1")), NewGreaterThanOrEqualTo(MustParse("1")), - NewWildcard(), - NewWildcard(), + NewMatchAll(), + NewMatchAll(), }, want: NewExactConstraint(MustParse("1")), wantErr: nil, @@ -239,8 +239,8 @@ func TestAnd(t *testing.T) { NewLessThanOrEqualTo(MustParse("1")), NewLessThan(MustParse("1")), NewLessThan(MustParse("1")), - NewWildcard(), - NewWildcard(), + NewMatchAll(), + NewMatchAll(), NewGreaterThan(MustParse("1")), }, want: nilC, @@ -253,8 +253,8 @@ func TestAnd(t *testing.T) { NewGreaterThanOrEqualTo(MustParse("1")), NewGreaterThan(MustParse("1")), NewGreaterThan(MustParse("1")), - NewWildcard(), - NewWildcard(), + NewMatchAll(), + NewMatchAll(), NewLessThan(MustParse("1")), }, want: nilC, @@ -267,8 +267,8 @@ func TestAnd(t *testing.T) { NewLessThanOrEqualTo(MustParse("1")), NewLessThan(MustParse("1")), NewLessThan(MustParse("1")), - NewWildcard(), - NewWildcard(), + NewMatchAll(), + NewMatchAll(), NewGreaterThanOrEqualTo(MustParse("1")), NewGreaterThanOrEqualTo(MustParse("1")), NewGreaterThan(MustParse("1")), @@ -381,7 +381,7 @@ func TestAnd(t *testing.T) { wantErr: nil, }, { - name: "compact_ceiling_floor_wildcard", + name: "compact_ceiling_floor_match_all", es: []Endless{ NewLessThanOrEqualTo(MustParse("4")), NewLessThan(MustParse("4")), @@ -391,7 +391,7 @@ func TestAnd(t *testing.T) { NewGreaterThanOrEqualTo(MustParse("2")), NewGreaterThan(MustParse("1")), NewGreaterThanOrEqualTo(MustParse("1")), - NewWildcard(), + NewMatchAll(), }, want: interval{ upper: NewLessThan(MustParse("3")), @@ -450,13 +450,13 @@ func Test_minBoundedCeiling(t *testing.T) { { name: "empty", cs: []Endless{}, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { name: "nil", cs: nil, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { @@ -474,19 +474,19 @@ func Test_minBoundedCeiling(t *testing.T) { { name: "single_greaterThan", cs: []Endless{NewGreaterThan(MustParse("3"))}, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { name: "single_greaterThanOrEqualTo", cs: []Endless{NewGreaterThanOrEqualTo(MustParse("4"))}, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { - name: "single_wildcard", - cs: []Endless{NewWildcard()}, - want: NewWildcard(), + name: "single_match_all", + cs: []Endless{NewMatchAll()}, + want: NewMatchAll(), wantOk: false, }, { @@ -497,19 +497,19 @@ func Test_minBoundedCeiling(t *testing.T) { NewGreaterThanOrEqualTo(MustParse("4")), NewGreaterThan(MustParse("4")), }, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { - name: "multiple_no_ceiling_wildcard", + name: "multiple_no_ceiling_match_all", cs: []Endless{ NewGreaterThanOrEqualTo(MustParse("3")), NewGreaterThan(MustParse("3")), NewGreaterThanOrEqualTo(MustParse("4")), NewGreaterThan(MustParse("4")), - NewWildcard(), + NewMatchAll(), }, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { @@ -542,7 +542,7 @@ func Test_minBoundedCeiling(t *testing.T) { wantOk: true, }, { - name: "multiple_ceilings_wildcard", + name: "multiple_ceilings_match_all", cs: []Endless{ NewLessThan(MustParse("1")), NewLessThanOrEqualTo(MustParse("1")), @@ -552,7 +552,7 @@ func Test_minBoundedCeiling(t *testing.T) { NewGreaterThan(MustParse("3")), NewGreaterThanOrEqualTo(MustParse("4")), NewGreaterThan(MustParse("4")), - NewWildcard(), + NewMatchAll(), }, want: NewLessThan(MustParse("1")), wantOk: true, @@ -570,14 +570,14 @@ func Test_minBoundedCeiling(t *testing.T) { wantOk: true, }, { - name: "single_ceiling_wildcard", + name: "single_ceiling_match_all", cs: []Endless{ NewLessThanOrEqualTo(MustParse("2")), NewGreaterThanOrEqualTo(MustParse("3")), NewGreaterThan(MustParse("3")), NewGreaterThanOrEqualTo(MustParse("4")), NewGreaterThan(MustParse("4")), - NewWildcard(), + NewMatchAll(), }, want: NewLessThanOrEqualTo(MustParse("2")), wantOk: true, @@ -627,25 +627,25 @@ func Test_maxBoundedFloor(t *testing.T) { { name: "empty", fs: []Endless{}, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { name: "nil", fs: nil, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { name: "single_lessThan", fs: []Endless{NewLessThan(MustParse("1"))}, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { name: "single_lessThanOrEqualTo", fs: []Endless{NewLessThanOrEqualTo(MustParse("2"))}, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { @@ -661,9 +661,9 @@ func Test_maxBoundedFloor(t *testing.T) { wantOk: true, }, { - name: "single_wildcard", - fs: []Endless{NewWildcard()}, - want: NewWildcard(), + name: "single_match_all", + fs: []Endless{NewMatchAll()}, + want: NewMatchAll(), wantOk: false, }, { @@ -674,19 +674,19 @@ func Test_maxBoundedFloor(t *testing.T) { NewLessThan(MustParse("2")), NewLessThanOrEqualTo(MustParse("2")), }, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { - name: "multiple_no_floor_wildcard", + name: "multiple_no_floor_match_all", fs: []Endless{ NewLessThan(MustParse("1")), NewLessThanOrEqualTo(MustParse("1")), NewLessThan(MustParse("2")), NewLessThanOrEqualTo(MustParse("2")), - NewWildcard(), + NewMatchAll(), }, - want: NewWildcard(), + want: NewMatchAll(), wantOk: false, }, { @@ -719,7 +719,7 @@ func Test_maxBoundedFloor(t *testing.T) { wantOk: true, }, { - name: "multiple_floors_wildcard", + name: "multiple_floors_match_all", fs: []Endless{ NewLessThan(MustParse("1")), NewLessThanOrEqualTo(MustParse("1")), @@ -729,7 +729,7 @@ func Test_maxBoundedFloor(t *testing.T) { NewGreaterThan(MustParse("3")), NewGreaterThanOrEqualTo(MustParse("4")), NewGreaterThan(MustParse("4")), - NewWildcard(), + NewMatchAll(), }, want: NewGreaterThan(MustParse("4")), wantOk: true, @@ -747,14 +747,14 @@ func Test_maxBoundedFloor(t *testing.T) { wantOk: true, }, { - name: "single_floor_wildcard", + name: "single_floor_match_all", fs: []Endless{ NewLessThan(MustParse("1")), NewLessThanOrEqualTo(MustParse("1")), NewLessThan(MustParse("2")), NewLessThanOrEqualTo(MustParse("2")), NewGreaterThan(MustParse("3")), - NewWildcard(), + NewMatchAll(), }, want: NewGreaterThan(MustParse("3")), wantOk: true, diff --git a/compact.go b/compact.go index 2936c33..2dffedf 100644 --- a/compact.go +++ b/compact.go @@ -14,8 +14,8 @@ func Compact(o Or) Constrainter { //nolint:cyclop,ireturn if len(o) == 1 { return o[0] } - if slices.ContainsFunc(o, wildcard) { - return NewWildcard() + if slices.ContainsFunc(o, matchAll) { + return NewMatchAll() } o = slices.Clone(o) @@ -23,13 +23,13 @@ func Compact(o Or) Constrainter { //nolint:cyclop,ireturn ceiling, ceilingOk := maxFloorlessCeiling(o...) floor, floorOk := minCeilinglessFloor(o...) - // short circuit if we have a wildcard - if ceilingOk && floorOk && matchAll(ceiling, floor) { - return NewWildcard() + // short circuit if we have a match all + if ceilingOk && floorOk && disjunctivelyCombineToMatchAll(ceiling, floor) { + return NewMatchAll() } o = slices.DeleteFunc(o, func(c CeilingFloorConstrainter) bool { - return c.ceiling().wildcard() || c.floor().wildcard() || + return c.ceiling().matchAll() || c.floor().matchAll() || (ceilingOk && ceiling.compare(c.ceiling()) >= 0) || (floorOk && floor.compare(c.floor()) <= 0) }) @@ -58,8 +58,8 @@ func Compact(o Or) Constrainter { //nolint:cyclop,ireturn return slices.Clip(r) } -func wildcard(c CeilingFloorConstrainter) bool { - return c.floor().wildcard() && c.ceiling().wildcard() +func matchAll(c CeilingFloorConstrainter) bool { + return c.floor().matchAll() && c.ceiling().matchAll() } func minCeilinglessFloor(cs ...CeilingFloorConstrainter) (Endless, bool) { @@ -67,7 +67,7 @@ func minCeilinglessFloor(cs ...CeilingFloorConstrainter) (Endless, bool) { o := slices.Clone(cs) cs = slices.DeleteFunc(cs, func(c CeilingFloorConstrainter) bool { - return !c.ceiling().wildcard() + return !c.ceiling().matchAll() }) if len(cs) == 0 { @@ -81,13 +81,13 @@ func minCeilinglessFloor(cs ...CeilingFloorConstrainter) (Endless, bool) { }).floor() o = slices.DeleteFunc(o, func(c CeilingFloorConstrainter) bool { - return c.ceiling().wildcard() || - c.floor().wildcard() + return c.ceiling().matchAll() || + c.floor().matchAll() }) for i := range o { if o[i].floor().compare(m) < 0 { - if o[i].Check(*m.version) || matchAll(o[i].ceiling(), m) { + if o[i].Check(*m.version) || disjunctivelyCombineToMatchAll(o[i].ceiling(), m) { m = o[i].floor() } @@ -111,7 +111,7 @@ func maxFloorlessCeiling(cs ...CeilingFloorConstrainter) (Endless, bool) { o := slices.Clone(cs) cs = slices.DeleteFunc(cs, func(c CeilingFloorConstrainter) bool { - return !c.floor().wildcard() + return !c.floor().matchAll() }) if len(cs) == 0 { @@ -125,12 +125,12 @@ func maxFloorlessCeiling(cs ...CeilingFloorConstrainter) (Endless, bool) { }).ceiling() o = slices.DeleteFunc(o, func(c CeilingFloorConstrainter) bool { - return c.ceiling().wildcard() || c.floor().wildcard() + return c.ceiling().matchAll() || c.floor().matchAll() }) for i := range o { if o[i].ceiling().compare(m) > 0 { - if o[i].Check(*m.version) || matchAll(o[i].floor(), m) { + if o[i].Check(*m.version) || disjunctivelyCombineToMatchAll(o[i].floor(), m) { m = o[i].ceiling() } @@ -149,7 +149,7 @@ func maxFloorlessCeiling(cs ...CeilingFloorConstrainter) (Endless, bool) { return m, true } -func matchAll(e, f Endless) bool { +func disjunctivelyCombineToMatchAll(e, f Endless) bool { if e.ceilingBounded() && f.ceilingBounded() { return false } diff --git a/compact_example_test.go b/compact_example_test.go index 496d20e..b60502e 100644 --- a/compact_example_test.go +++ b/compact_example_test.go @@ -51,7 +51,7 @@ func ExampleCompact_endless() { // After: >3 } -func ExampleCompact_wildcard() { +func ExampleCompact_matchAll() { o := comver.Or{ comver.NewLessThan(comver.MustParse("3")), comver.NewGreaterThan(comver.MustParse("2")), @@ -67,13 +67,13 @@ func ExampleCompact_wildcard() { // After: * } -func ExampleCompact_wildcardTrumps() { +func ExampleCompact_matchAllTrumps() { o := comver.Or{ comver.MustAnd( comver.NewLessThan(comver.MustParse("2")), comver.NewGreaterThan(comver.MustParse("1")), ), - comver.NewWildcard(), + comver.NewMatchAll(), } c := comver.Compact(o) diff --git a/compact_test.go b/compact_test.go index 260d3aa..2473439 100644 --- a/compact_test.go +++ b/compact_test.go @@ -66,17 +66,17 @@ func TestCompact(t *testing.T) { }, }, { - name: "single_wildcard", - o: Or{NewWildcard()}, - want: NewWildcard(), + name: "single_match_all", + o: Or{NewMatchAll()}, + want: NewMatchAll(), }, { - name: "multiple_wildcards", - o: Or{NewWildcard(), NewWildcard()}, - want: NewWildcard(), + name: "multiple_match_alls", + o: Or{NewMatchAll(), NewMatchAll()}, + want: NewMatchAll(), }, { - name: "wildcard_trumps_everything_else", + name: "match_all_trumps_everything_else", o: Or{ NewLessThan(MustParse("1")), NewLessThanOrEqualTo(MustParse("1")), @@ -91,9 +91,9 @@ func TestCompact(t *testing.T) { upper: NewLessThan(MustParse("7")), lower: NewGreaterThan(MustParse("6")), }, - NewWildcard(), + NewMatchAll(), }, - want: NewWildcard(), + want: NewMatchAll(), }, { name: "match_all", @@ -101,7 +101,7 @@ func TestCompact(t *testing.T) { NewLessThan(MustParse("10")), NewGreaterThan(MustParse("9")), }, - want: NewWildcard(), + want: NewMatchAll(), }, { name: "match_all_same_version_ceiling_inclusive_floor_inclusive", @@ -109,7 +109,7 @@ func TestCompact(t *testing.T) { NewLessThanOrEqualTo(MustParse("10")), NewGreaterThanOrEqualTo(MustParse("10")), }, - want: NewWildcard(), + want: NewMatchAll(), }, { name: "match_all_same_version_ceiling_non_inclusive_floor_inclusive", @@ -117,7 +117,7 @@ func TestCompact(t *testing.T) { NewLessThan(MustParse("10")), NewGreaterThanOrEqualTo(MustParse("10")), }, - want: NewWildcard(), + want: NewMatchAll(), }, { name: "match_all_same_version_ceiling_inclusive_floor_non_inclusive", @@ -125,7 +125,7 @@ func TestCompact(t *testing.T) { NewLessThanOrEqualTo(MustParse("10")), NewGreaterThan(MustParse("10")), }, - want: NewWildcard(), + want: NewMatchAll(), }, { name: "same_version_not_match_all", @@ -1464,7 +1464,7 @@ func TestCompact(t *testing.T) { }, NewLessThan(MustParse("4")), }, - want: NewWildcard(), + want: NewMatchAll(), }, { name: "match_all_within_interval", @@ -1476,7 +1476,7 @@ func TestCompact(t *testing.T) { }, NewLessThan(MustParse("3")), }, - want: NewWildcard(), + want: NewMatchAll(), }, { name: "match_all_within_intervals", @@ -1492,7 +1492,7 @@ func TestCompact(t *testing.T) { }, NewGreaterThan(MustParse("7")), }, - want: NewWildcard(), + want: NewMatchAll(), }, } for _, tt := range tests { @@ -1524,7 +1524,7 @@ func TestCompact(t *testing.T) { } } -func Test_wildcard(t *testing.T) { +func Test_matchAll(t *testing.T) { t.Parallel() tests := []struct { @@ -1566,8 +1566,8 @@ func Test_wildcard(t *testing.T) { want: false, }, { - name: "wildcard", - c: NewWildcard(), + name: "matchAll", + c: NewMatchAll(), want: true, }, } @@ -1575,8 +1575,8 @@ func Test_wildcard(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - if got := wildcard(tt.c); got != tt.want { - t.Errorf("wildcard() = %v, want %v", got, tt.want) + if got := matchAll(tt.c); got != tt.want { + t.Errorf("disjunctivelyCombineToMatchAll() = %v, want %v", got, tt.want) } }) } diff --git a/endless.go b/endless.go index afcfa9e..96eac59 100644 --- a/endless.go +++ b/endless.go @@ -1,12 +1,14 @@ package comver // Endless represents a constraint that is either floor bounded, ceiling bounded, -// or wildcard (satisfied by any version). -// The zero value for Endless is a wildcard constraint (satisfied by any version). +// or [match all]. +// The zero value for Endless is a [match all] constraint which satisfied by any [Version]. +// +// [match all]: https://github.com/composer/semver/blob/main/src/Constraint/MatchAllConstraint.php type Endless struct { // The version used in the constraint check, // e.g.: the version representing 1.2.3 in '<=1.2.3'. - // If nil, the Endless is a wildcard satisfied by any version. + // If nil, the Endless is a match all constraint which satisfied by any version. version *Version op op } @@ -39,7 +41,7 @@ func NewGreaterThanOrEqualTo(v Version) Endless { } } -func NewWildcard() Endless { +func NewMatchAll() Endless { return Endless{ //nolint:exhaustruct version: nil, } @@ -48,7 +50,7 @@ func NewWildcard() Endless { // Check reports whether a [Version] satisfies the constraint. func (b Endless) Check(v Version) bool { if b.version == nil { - // this is wildcard, match all versions + // this is disjunctivelyCombineToMatchAll, match all versions return true } @@ -71,7 +73,7 @@ func (b Endless) Check(v Version) bool { func (b Endless) ceiling() Endless { if !b.ceilingBounded() { - return NewWildcard() + return NewMatchAll() } return b @@ -79,21 +81,21 @@ func (b Endless) ceiling() Endless { func (b Endless) floor() Endless { if !b.floorBounded() { - return NewWildcard() + return NewMatchAll() } return b } func (b Endless) String() string { - if b.wildcard() { + if b.matchAll() { return "*" } return b.op.String() + b.version.Short() } -func (b Endless) wildcard() bool { +func (b Endless) matchAll() bool { return b.version == nil } @@ -102,21 +104,21 @@ func (b Endless) wildcard() bool { // The comparison is done by comparing the version first, then the operator. // - Versions are compared according to their semantic precedence // - Operators are compared in the following order (lowest to highest): >=, >, <, <= -// - wildcard [Endless] is considered to be higher than ceiling bounded [Endless] while +// - matchAll [Endless] is considered to be higher than ceiling bounded [Endless] while // floor than floor bounded [Endless] // // The result is 0 when b == d, -1 when b < d, or +1 when b > d. func (b Endless) compare(d Endless) int { switch { - case b.wildcard() && d.wildcard(): + case b.matchAll() && d.matchAll(): return 0 - case b.wildcard(): + case b.matchAll(): if d.floorBounded() { return -1 } return +1 - case d.wildcard(): + case d.matchAll(): if b.floorBounded() { return +1 } diff --git a/endless_test.go b/endless_test.go index 32ff838..2673ba5 100644 --- a/endless_test.go +++ b/endless_test.go @@ -114,8 +114,8 @@ func TestEndless_Check(t *testing.T) { want: false, }, { - name: "wildcard", - endless: NewWildcard(), + name: "disjunctivelyCombineToMatchAll", + endless: NewMatchAll(), version: MustParse("1"), want: true, }, @@ -153,17 +153,17 @@ func TestEndless_Ceiling(t *testing.T) { { name: "greaterThanOrEqualTo", endless: NewGreaterThanOrEqualTo(MustParse("3")), - want: NewWildcard(), + want: NewMatchAll(), }, { name: "greaterThan", endless: NewGreaterThan(MustParse("4")), - want: NewWildcard(), + want: NewMatchAll(), }, { - name: "wildcard", - endless: NewWildcard(), - want: NewWildcard(), + name: "disjunctivelyCombineToMatchAll", + endless: NewMatchAll(), + want: NewMatchAll(), }, } @@ -189,12 +189,12 @@ func TestEndless_Floor(t *testing.T) { { name: "lessThan", endless: NewLessThan(MustParse("1")), - want: NewWildcard(), + want: NewMatchAll(), }, { name: "lessThanOrEqualTo", endless: NewLessThanOrEqualTo(MustParse("2")), - want: NewWildcard(), + want: NewMatchAll(), }, { name: "greaterThanOrEqualTo", @@ -207,9 +207,9 @@ func TestEndless_Floor(t *testing.T) { want: NewGreaterThan(MustParse("4")), }, { - name: "wildcard", - endless: NewWildcard(), - want: NewWildcard(), + name: "disjunctivelyCombineToMatchAll", + endless: NewMatchAll(), + want: NewMatchAll(), }, } @@ -224,7 +224,7 @@ func TestEndless_Floor(t *testing.T) { } } -func TestEndless_wildcard(t *testing.T) { +func TestEndless_matchAll(t *testing.T) { t.Parallel() tests := []struct { @@ -253,8 +253,8 @@ func TestEndless_wildcard(t *testing.T) { want: false, }, { - name: "wildcard", - endless: NewWildcard(), + name: "disjunctivelyCombineToMatchAll", + endless: NewMatchAll(), want: true, }, } @@ -262,8 +262,8 @@ func TestEndless_wildcard(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - if got := tt.endless.wildcard(); got != tt.want { - t.Errorf("wildcard() = %v, want %v", got, tt.want) + if got := tt.endless.matchAll(); got != tt.want { + t.Errorf("disjunctivelyCombineToMatchAll() = %v, want %v", got, tt.want) } }) } @@ -293,7 +293,7 @@ func TestEndless_String(t *testing.T) { want: ">=2", }, { - endless: NewWildcard(), + endless: NewMatchAll(), want: "*", }, } diff --git a/interval.go b/interval.go index 865c135..102dc9d 100644 --- a/interval.go +++ b/interval.go @@ -2,7 +2,6 @@ package comver // interval represents a constraint that is both floor bounded and ceiling bounded. // It must be initialized via [And]. -// The zero value for interval is a constraint could never be satisfied. type interval struct { upper Endless lower Endless diff --git a/or.go b/or.go index 8b83cef..de161f2 100644 --- a/or.go +++ b/or.go @@ -4,7 +4,9 @@ package comver // TODO: Make Or to be []Constrainter so that we can nest Or // Or represents a logical OR operation between multiple [CeilingFloorConstrainter] instances. -// The zero value for Or is a constraint could never be satisfied. +// The zero value for Or is a [match none] constraint which could never be satisfied. +// +// [match none]: https://github.com/composer/semver/blob/main/src/Constraint/MatchNoneConstraint.php type Or []CeilingFloorConstrainter // Check reports whether a [Version] satisfies the constraint. diff --git a/version.go b/version.go index 836ddc3..56c79ad 100644 --- a/version.go +++ b/version.go @@ -23,7 +23,7 @@ var ( ) // Version represents a single composer version. -// The zero value for Version is v0.0.0.0 with an empty original string. +// The zero value for Version is v0.0.0.0 with empty original string. type Version struct { major, minor, patch, tweak uint64 `exhaustruct:"optional"` modifier modifier `exhaustruct:"optional"`