diff --git a/tests/Unit/Module/Binary/BinaryVersionTest.php b/tests/Unit/Module/Binary/BinaryVersionTest.php index 2a29174..6794bd8 100644 --- a/tests/Unit/Module/Binary/BinaryVersionTest.php +++ b/tests/Unit/Module/Binary/BinaryVersionTest.php @@ -263,6 +263,23 @@ public function preReleaseGluedToTheNumberKeepsItsStability(string $output, Stab Assert::same(BinaryVersion::fromBinaryOutput($output)->stability, $stability); } + #[DataSet(['tool 1.2.3beta2', '1.2.3', Stability::Beta, 2], 'beta word with a number')] + #[DataSet(['tool 2.0.0alpha', '2.0.0', Stability::Alpha, 0], 'alpha word')] + #[Test] + public function preReleaseWordGluedToTheNumberIsNotAPatchLetter( + string $output, + string $number, + Stability $stability, + int $preReleaseNumber, + ): void { + $result = BinaryVersion::fromBinaryOutput($output); + + Assert::same($result->number, $number); + Assert::same($result->stability, $stability); + Assert::same($result->preRelease?->stability, $stability); + Assert::same($result->preRelease?->number, $preReleaseNumber); + } + /** * Tests that the resolver correctly extracts versions using fallback patterns. */ diff --git a/tests/Unit/Module/Version/ConstraintTest.php b/tests/Unit/Module/Version/ConstraintTest.php index ec18c74..f7911a7 100644 --- a/tests/Unit/Module/Version/ConstraintTest.php +++ b/tests/Unit/Module/Version/ConstraintTest.php @@ -249,6 +249,9 @@ public static function provideValidConstraints(): \Generator yield 'pre-release lower bound of a hyphen range' => ['1.0.0-beta.1 - 2.0.0', '1.0.0-beta.1 - 2.0.0', null, Stability::Beta, 'Pre-release hyphen range']; yield 'least stable of pre-release bounds' => ['>=1.0.0-alpha.1 <2.0.0-RC1', '>=1.0.0-alpha.1 <2.0.0-RC1', null, Stability::Alpha, 'Least stable bound']; yield 'bare stability keyword in a range' => ['>=1.0-beta <2.0', '>=1.0-beta <2.0', null, Stability::Beta, 'Bare keyword bound']; + yield 'bare stability keyword before alternatives without spaces' => ['^1.0-beta||^2.0', '^1.0-beta||^2.0', null, Stability::Beta, 'Bare keyword before ||']; + yield 'pre-release after alternatives without spaces' => ['^1.0||^2.0-beta.1', '^1.0||^2.0-beta.1', null, Stability::Beta, 'Pre-release after ||']; + yield 'least stable bound last' => ['>=1.0-RC1 || ^2.0-alpha.1', '>=1.0-RC1 || ^2.0-alpha.1', null, Stability::Alpha, 'Least stable bound last']; yield 'explicit stability over pre-release bounds' => ['>=3.5.0-beta.1 <3.5.0@alpha', '>=3.5.0-beta.1 <3.5.0', null, Stability::Alpha, 'Explicit stability']; yield 'pre-release bound with a space after the operator' => ['>= 1.0-beta.1 <2.0', '>= 1.0-beta.1 <2.0', null, Stability::Beta, 'Spaced bound']; yield 'bare stability keywords of a hyphen range' => ['1.0-beta - 2.0-RC1', '1.0-beta - 2.0-RC1', null, Stability::Beta, 'Hyphen range bounds']; @@ -548,6 +551,17 @@ public static function provideComparableConstraints(): \Generator yield 'upper bound without a pre-release below every build of its number' => ['>=3.5.0-beta.1 <3.5.0', 'v3.5.0-beta.2', false]; yield 'pre-release alternative on its bound' => ['^1.0 || ^2.0-beta.1', 'v2.0.0-beta.1', true]; yield 'pre-release alternative on another alternative' => ['^1.0 || ^2.0-beta.1', 'v1.5.0', true]; + yield 'bare keyword before alternatives without spaces on its bound' => ['^1.0-beta||^2.0', 'v1.0.0-beta', true]; + yield 'bare keyword before alternatives without spaces below its bound' => ['^1.0-beta||^2.0', 'v1.0.0-alpha', false]; + yield 'bare keyword before alternatives without spaces on another alternative' => ['^1.0-beta||^2.0', 'v2.5.0', true]; + yield 'bare keyword before alternatives without spaces past them' => ['^1.0-beta||^2.0', 'v3.0.0', false]; + yield 'pre-release after alternatives without spaces on its bound' => ['^1.0||^2.0-beta.1', 'v2.0.0-beta.1', true]; + yield 'pre-release after alternatives without spaces below its bound' => ['^1.0||^2.0-beta.1', 'v2.0.0-alpha.1', false]; + yield 'pre-release after alternatives without spaces on another alternative' => ['^1.0||^2.0-beta.1', 'v1.5.0', true]; + yield 'pre-release after alternatives without spaces past them' => ['^1.0||^2.0-beta.1', 'v3.0.0', false]; + yield 'least stable bound last on its bound' => ['>=1.0-RC1 || ^2.0-alpha.1', 'v2.0.0-alpha.1', true]; + yield 'least stable bound last on a later alpha' => ['>=1.0-RC1 || ^2.0-alpha.1', 'v2.1.0-alpha', true]; + yield 'least stable bound last below the first bound' => ['>=1.0-RC1 || ^2.0-alpha.1', 'v1.0.0-beta', false]; yield 'pre-release upper bound on a release below it' => ['>=1.0 <2.0-RC1', 'v1.5.0', true]; yield 'pre-release upper bound on its bound' => ['>=1.0 <2.0-RC1', 'v2.0.0-RC1', false]; yield 'pre-release upper bound below the stability' => ['>=1.0 <2.0-RC1', 'v2.0.0-beta', false]; diff --git a/tests/Unit/Module/Version/RangeTest.php b/tests/Unit/Module/Version/RangeTest.php index 0e0339c..da44165 100644 --- a/tests/Unit/Module/Version/RangeTest.php +++ b/tests/Unit/Module/Version/RangeTest.php @@ -257,6 +257,20 @@ public static function provideMatches(): \Generator yield ['~1.0.0-1', '1.0.9', true]; yield ['~1.0.0-1', '1.1', false]; + // Incrementing a part that ends in nines carries over + yield ['9.*', '9.5', true]; + yield ['9.*', '10.0', false]; + yield ['~1.9', '1.10', true]; + yield ['~9.9', '9.10', true]; + yield ['~9.9', '10.0', false]; + yield ['^0.99', '0.99.5', true]; + yield ['^0.99', '0.100', false]; + yield ['1.99.*', '1.99.5', true]; + yield ['1.99.*', '1.100.0', false]; + yield ['1.19.*', '1.19.9', true]; + yield ['1.19.*', '1.25', false]; + yield ['^0.199', '0.200', false]; + // Number parts past the integer range yield ['^99999999999999999999', '1.0', false]; yield ['~9223372036854775807', '1.0', false];