semver icon indicating copy to clipboard operation
semver copied to clipboard

range issue perhaps?

Open twoofy opened this issue 7 years ago • 1 comments
trafficstars

I was trying to figure out what might be causing some unexpected behavior in this package. To be honest, I'm not sure if this is something I'm doing wrong or not.

I added some extra code to range_test.go, which I think shows the issue:

		{">1.2.2 <1.2.4", []tv{
			{"1.2.1", false},
			{"1.2.1-pl1", false},
			{"1.2.2", false},
			{"1.2.2-pl1", false},
			{"1.2.3", true},
			{"1.2.3-pl1", true},
			{"1.2.4", false},
			{"1.2.4-pl1", false},
		}},
		{">=1.2.2 <1.2.4", []tv{
			{"1.2.1", false},
			{"1.2.1-pl1", false},
			{"1.2.2", true},
			{"1.2.2-pl1", true},
			{"1.2.3", true},
			{"1.2.3-pl1", true},
			{"1.2.4", false},
			{"1.2.4-pl1", false},
		}},

The issue is that versions with -pl1 seem to return different results then those without.

The output of the above is:

--- FAIL: TestParseRange (0.00s)
	range_test.go:514: Invalid for case ">1.2.2 <1.2.4" matching "1.2.4-pl1": Expected false, got: true
	range_test.go:514: Invalid for case ">=1.2.2 <1.2.4" matching "1.2.2-pl1": Expected true, got: false
	range_test.go:514: Invalid for case ">=1.2.2 <1.2.4" matching "1.2.4-pl1": Expected false, got: true
FAIL
exit status 1
FAIL	github.com/blang/semver	0.007s

Am I doing something wrong here?

  • Greg

twoofy avatar Jul 13 '18 21:07 twoofy

1.2.4-pl1 < 1.2.4 is true according to spec Section 11: https://semver.org/#spec-item-11

blang avatar Dec 08 '18 17:12 blang