-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add function to invert constraints and ranges #91 #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
96ac3b8
4d32ece
54facef
2bec4bf
4218340
637d362
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,3 +393,20 @@ def test_npm_advisory_version_range_parse(test_case): | |
| string=test_case["npm_native"], | ||
| ) | ||
| assert str(result) == test_case["expected_vers"] | ||
|
|
||
|
|
||
| def test_inverse(): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need tests for the lower level constraint.invert e.g., for https://github.com/nexB/univers/pull/92/files#diff-c77d34029ce1991650937489359eef45029f37be4f1f27c21f56e50e64209d9aR138 too
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
| vers_with_equal_operator = VersionRange.from_string("vers:gem/1.0") | ||
| assert str(vers_with_equal_operator.invert()) == "vers:gem/!=1.0" | ||
| assert VersionRange.from_string("vers:gem/!=1.0").invert() == vers_with_equal_operator | ||
|
|
||
| vers_with_less_than_operator = VersionRange.from_string("vers:gem/<1.0") | ||
| assert str(vers_with_less_than_operator.invert()) == "vers:gem/>=1.0" | ||
| assert VersionRange.from_string("vers:gem/>=1.0").invert() == vers_with_less_than_operator | ||
|
|
||
| vers_with_greater_than_operator = VersionRange.from_string("vers:gem/>1.0") | ||
| assert str(vers_with_greater_than_operator.invert()) == "vers:gem/<=1.0" | ||
| assert VersionRange.from_string("vers:gem/<=1.0").invert() == vers_with_greater_than_operator | ||
|
|
||
| vers_with_complex_constraints = VersionRange.from_string("vers:gem/<=1.0|>=3.0|<4.0|!=5.0") | ||
| assert str(vers_with_complex_constraints.invert()) == "vers:gem/>1.0|<3.0|>=4.0|5.0" | ||
Uh oh!
There was an error while loading. Please reload this page.