mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix semver matcher differently.
This commit is contained in:
parent
69e450038c
commit
9c3503834d
@ -18,7 +18,7 @@ Bugfixes:
|
||||
* SMTChecker: Fix internal error when using ``abi.decode``.
|
||||
* SMTChecker: Fix internal error when using arrays or mappings of functions.
|
||||
* SMTChecker: Fix internal error in array of structs type.
|
||||
* Version Checker: 0.5.x-prerelease will match `pragma solidity ^0.5`.
|
||||
* Version Checker: ``^0`` should match ``0.5.0``, but no prerelease.
|
||||
* Yul: Consider infinite loops and recursion to be not removable.
|
||||
|
||||
|
||||
|
@ -88,7 +88,7 @@ bool SemVerMatchExpression::MatchComponent::matches(SemVerVersion const& _versio
|
||||
if (!comp.matches(_version))
|
||||
return false;
|
||||
|
||||
if (comp.version.numbers[0] == 0)
|
||||
if (comp.version.numbers[0] == 0 && comp.levelsPresent != 1)
|
||||
comp.levelsPresent = 2;
|
||||
else
|
||||
comp.levelsPresent = 1;
|
||||
@ -107,17 +107,7 @@ bool SemVerMatchExpression::MatchComponent::matches(SemVerVersion const& _versio
|
||||
}
|
||||
|
||||
if (cmp == 0 && !_version.prerelease.empty() && didCompare)
|
||||
{
|
||||
cmp = -1;
|
||||
for (unsigned i = levelsPresent; i < 3; i++)
|
||||
{
|
||||
if (_version.numbers[i] > 0)
|
||||
{
|
||||
cmp = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (prefix)
|
||||
{
|
||||
|
@ -141,14 +141,14 @@ BOOST_AUTO_TEST_CASE(positive_range)
|
||||
{"^0.1.2", "0.1.2"},
|
||||
{"^0.1", "0.1.2"},
|
||||
{"^1.2", "1.4.2"},
|
||||
{"^1.2", "1.2.1-pre"},
|
||||
{"^1.2", "1.2.0"},
|
||||
{"^1", "1.2.0-pre"},
|
||||
{"^1", "1.2.0"},
|
||||
{"<=1.2.3", "1.2.3-beta"},
|
||||
{">1.2", "1.3.0-beta"},
|
||||
{"<1.2.3", "1.2.3-beta"},
|
||||
{"^1.2 ^1", "1.4.2"}
|
||||
{"^1.2 ^1", "1.4.2"},
|
||||
{"^0", "0.5.1"},
|
||||
{"^0", "0.1.1"},
|
||||
};
|
||||
for (auto const& t: tests)
|
||||
{
|
||||
@ -163,13 +163,14 @@ BOOST_AUTO_TEST_CASE(positive_range)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(negative_range)
|
||||
{
|
||||
// Positive range tests
|
||||
// Negative range tests
|
||||
vector<pair<string, string>> tests = {
|
||||
{"1.0.0 - 2.0.0", "2.2.3"},
|
||||
{"1.0", "1.0.0-pre"},
|
||||
{"1", "1.0.0-pre"},
|
||||
{"^1.2.3", "1.2.3-pre"},
|
||||
{"^1.2", "1.2.0-pre"},
|
||||
{"^1.2", "1.2.1-pre"},
|
||||
{"^1.2.3", "1.2.3-beta"},
|
||||
{"=0.7.x", "0.7.0-asdf"},
|
||||
{">=0.7.x", "0.7.0-asdf"},
|
||||
@ -212,8 +213,16 @@ BOOST_AUTO_TEST_CASE(negative_range)
|
||||
{"=1.2.3", "1.2.3-beta"},
|
||||
{">1.2", "1.2.8"},
|
||||
{"^1.2.3", "2.0.0-alpha"},
|
||||
{"^0.6", "0.6.2-alpha"},
|
||||
{"^0.6", "0.6.0-alpha"},
|
||||
{"^1.2", "1.2.1-pre"},
|
||||
{"^1.2.3", "1.2.2"},
|
||||
{"^1.2", "1.1.9"}
|
||||
{"^1", "1.2.0-pre"},
|
||||
{"^1", "1.2.0-pre"},
|
||||
{"^1.2", "1.1.9"},
|
||||
{"^0", "0.5.1-pre"},
|
||||
{"^0", "0.0.0-pre"},
|
||||
{"^0", "1.0.0"},
|
||||
};
|
||||
for (auto const& t: tests)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user