aboutsummaryrefslogtreecommitdiff
path: root/tests/standard-version
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-05-04 23:42:51 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-05-05 16:02:10 +0300
commit166c3167bc608a63e2312930a9b722f8d697d2c5 (patch)
tree086b2b42f34414b45919ea1a7bf42ffb18f887d8 /tests/standard-version
parentb5b66e6a831cf68b7da764235f669fad758491fb (diff)
Add support for standard version constraint shortcut operators
Diffstat (limited to 'tests/standard-version')
-rw-r--r--tests/standard-version/driver.cxx26
-rw-r--r--tests/standard-version/testscript93
2 files changed, 118 insertions, 1 deletions
diff --git a/tests/standard-version/driver.cxx b/tests/standard-version/driver.cxx
index c6f9c11..1eb1bc8 100644
--- a/tests/standard-version/driver.cxx
+++ b/tests/standard-version/driver.cxx
@@ -76,6 +76,32 @@ version (const string& s,
assert (r == v);
}
+ if (!r.stub ())
+ {
+ auto max_ver = [&v] (char c) -> string
+ {
+ string e (v.epoch != 0 ? '+' + to_string (v.epoch) + '-' : string ());
+
+ return c == '~' || v.major () == 0
+ ? e + to_string (v.major ()) + '.' + to_string (v.minor () + 1) + ".0-"
+ : e + to_string (v.major () + 1) + ".0.0-";
+ };
+
+ if (v.minor () != 999)
+ {
+ standard_version_constraint c1 ("~" + s);
+ standard_version_constraint c2 ('[' + s + ' ' + max_ver ('~') + ')');
+ assert (c1 == c2);
+ }
+
+ if ((v.major () == 0 && v.minor () != 999) ||
+ (v.major () != 0 && v.major () != 999))
+ {
+ standard_version_constraint c1 ("^" + s);
+ standard_version_constraint c2 ('[' + s + ' ' + max_ver ('^') + ')');
+ assert (c1 == c2);
+ }
+ }
}
catch (const invalid_argument& e)
{
diff --git a/tests/standard-version/testscript b/tests/standard-version/testscript
index f06b178..65c446b 100644
--- a/tests/standard-version/testscript
+++ b/tests/standard-version/testscript
@@ -66,6 +66,14 @@
$* <<EOF >>EOF
EOF
+
+ : max
+ :
+ $* <<EOF >>EOF
+ 1.2.999
+ 1.999.999
+ 999.999.999
+ EOF
}
: invalid
@@ -236,10 +244,12 @@
[1.2.3 1.2.4]
(1.2.3 1.2.4)
[ 1.2.3- 1.2.4- ]
+ [1.999.0 2.0.0)
EOI
[1.2.3 1.2.4]
(1.2.3 1.2.4)
[1.2.3- 1.2.4-]
+ [1.999.0 2.0.0)
EOE
: invalid
@@ -262,7 +272,7 @@
: min-gt-max
:
- $* <'[1.2.4 1.2.3]' 2>'min version is greater than max version' == 1
+ $* <'[999.0.0 1.0.0)' 2>'min version is greater than max version' == 1
: open-end
:
@@ -319,6 +329,53 @@
$* <'>= 1.2.3-a.1.1.ads@' 2>'invalid version: junk after version' == 1
}
}
+
+ : shortcut
+ :
+ {
+ : valid
+ :
+ $* <<EOI >>EOO
+ ~1.2.3
+ ^1.2.3
+ ^0.2.3
+ ~1.2.3-
+ ^1.2.3-
+ ^0.2.3-
+ ~1.2.3-a.1
+ ^1.2.3-a.1
+ ^0.2.3-a.1
+ ~1.2.3-a.1.123
+ ^1.2.3-a.1.123
+ ^0.2.3-a.1.123
+ ~ 1.2.3
+ EOI
+ ~1.2.3
+ ^1.2.3
+ ^0.2.3
+ ~1.2.3-
+ ^1.2.3-
+ ^0.2.3-
+ ~1.2.3-a.1
+ ^1.2.3-a.1
+ ^0.2.3-a.1
+ ~1.2.3-a.1.123
+ ^1.2.3-a.1.123
+ ^0.2.3-a.1.123
+ ~1.2.3
+ EOO
+
+ : invalid
+ :
+ {
+ $* <'-1.2.3' 2>'invalid constraint' == 1 : bad-char
+ $* <'~' 2>'no version' == 1 : no-version
+ $* <'~1.2' 2>"'.' expected after minor version" == 1 : bad-ver
+ $* <'~1.999.0' 2>"invalid minor version" == 1 : bad-min-tilde
+ $* <'^0.999.0' 2>"invalid minor version" == 1 : bad-min-caret
+ $* <'^999.0.0' 2>"invalid major version" == 1 : bad-maj-caret
+ }
+ }
}
: satisfaction
@@ -401,4 +458,38 @@
$* '1.2.3' '[1.2.1 1.2.2)' >n : open
}
}
+
+ : shortcut
+ :
+ {
+ : tilde
+ :
+ {
+ $* '1.2.3-b.499' '~1.2.3' >n : out-left
+ $* '1.2.3' '~1.2.3' >y : in-left
+ $* '1.2.4' '~1.2.3' >y : in
+ $* '1.2.999' '~1.2.3' >y : in-right
+ $* '1.3.0-' '~1.2.3' >n : out-right
+ }
+
+ : caret
+ :
+ {
+ $* '1.2.3-b.499' '^1.2.3' >n : out-left
+ $* '1.2.3' '^1.2.3' >y : in-left
+ $* '1.3.0' '^1.2.3' >y : in
+ $* '1.999.999' '^1.2.3' >y : in-right
+ $* '2.0.0-' '^1.2.3' >n : out-right
+ }
+
+ : caret-zero-major
+ :
+ {
+ $* '0.2.3-b.499' '^0.2.3' >n : out-left
+ $* '0.2.3' '^0.2.3' >y : in-left
+ $* '0.2.4' '^0.2.3' >y : in
+ $* '0.2.999' '^0.2.3' >y : in-right
+ $* '0.3.0-' '^0.2.3' >n : out-right
+ }
+ }
}