I used this earlier, though they are based on semver 2.0.0-rc.2 and therefore include ordering of metadata as well, but generally this is how you could do it.
<!-- gh-comment-id:324167307 -->
@FichteFoll commented on GitHub (Aug 22, 2017):
How about using unittests?
I used this earlier, though they are based on semver 2.0.0-rc.2 and therefore include ordering of metadata as well, but generally this is how you could do it.
https://github.com/FichteFoll/pysemver/blob/a5f78ecc461ac638d86ac51ac31387f38523278c/_test.py#L32-L50
(actual tests in line 70)
@handicraftsman commented on GitHub (Aug 23, 2017):
I am not actually familiar with unittests in C. So i am just using a test program. But i should really move to unittests for such stuff after finishing the whole semver implementation.
<!-- gh-comment-id:324295814 -->
@handicraftsman commented on GitHub (Aug 23, 2017):
I am not actually familiar with unittests in C. So i am just using a test program. But i should really move to unittests for such stuff after finishing the whole semver implementation.
But i should really move to unittests for such stuff after finishing the whole semver implementation.
Many would argue that you should never have started without them.
The answer to your question is no, your logic is broken. You are trying to process the prerelease field as if it were a simple string of characters. That is incorrect. From the spec #11:
Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows: identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order. Numeric identifiers always have lower precedence than non-numeric identifiers. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
As you can see, you must identify the type of each identifier first, then apply the appropriate logic.
<!-- gh-comment-id:429067416 -->
@jwdonahue commented on GitHub (Oct 11, 2018):
@handicraftsman said:
> But i should really move to unittests for such stuff after finishing the whole semver implementation.
Many would argue that you should never have started without them.
The answer to your question is no, your logic is broken. You are trying to process the prerelease field as if it were a simple string of characters. That is incorrect. From the [spec #11](https://semver.org/#spec-item-11):
> Precedence for two pre-release versions with the same major, minor, and patch version MUST be determined by comparing each dot separated identifier from left to right until a difference is found as follows: identifiers consisting of only digits are compared numerically and identifiers with letters or hyphens are compared lexically in ASCII sort order. Numeric identifiers always have lower precedence than non-numeric identifiers. A larger set of pre-release fields has a higher precedence than a smaller set, if all of the preceding identifiers are equal.
As you can see, you must identify the type of each identifier first, then apply the appropriate logic.
@handicraftsman , please take any further code reviews to Stackoverflow and use the semver tag and please close this issue at your earliest possible convenience.
<!-- gh-comment-id:429068650 -->
@jwdonahue commented on GitHub (Oct 11, 2018):
@handicraftsman , please take any further code reviews to Stackoverflow and use the semver tag and please close this issue at your earliest possible convenience.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @handicraftsman on GitHub (Aug 22, 2017).
Original GitHub issue: https://github.com/semver/semver/issues/388
@handicraftsman commented on GitHub (Aug 22, 2017):
Typedefs:
@FichteFoll commented on GitHub (Aug 22, 2017):
How about using unittests?
I used this earlier, though they are based on semver 2.0.0-rc.2 and therefore include ordering of metadata as well, but generally this is how you could do it.
https://github.com/FichteFoll/pysemver/blob/a5f78ecc461ac638d86ac51ac31387f38523278c/_test.py#L32-L50
(actual tests in line 70)
@handicraftsman commented on GitHub (Aug 23, 2017):
I am not actually familiar with unittests in C. So i am just using a test program. But i should really move to unittests for such stuff after finishing the whole semver implementation.
@jwdonahue commented on GitHub (Oct 11, 2018):
@handicraftsman said:
Many would argue that you should never have started without them.
The answer to your question is no, your logic is broken. You are trying to process the prerelease field as if it were a simple string of characters. That is incorrect. From the spec #11:
As you can see, you must identify the type of each identifier first, then apply the appropriate logic.
@jwdonahue commented on GitHub (Oct 11, 2018):
@handicraftsman , please take any further code reviews to Stackoverflow and use the semver tag and please close this issue at your earliest possible convenience.
@handicraftsman commented on GitHub (Oct 11, 2018):
Okay, sorry. Completely forgot about this issue ;shrugs;