summaryrefslogtreecommitdiff
path: root/scripts/t
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2018-04-08 22:43:09 +0200
committerGuillem Jover <guillem@debian.org>2018-05-04 04:39:28 +0200
commit981a18c37036b68f368b0bfab71d2a984abba9e6 (patch)
treeec082042e04e7a20ea65eb7fe278f5d701cf1247 /scripts/t
parentfd8f838450ab89e3011c1a48061e0247d205ea96 (diff)
downloaddpkg-981a18c37036b68f368b0bfab71d2a984abba9e6.tar.gz
Dpkg::Version: Fix bool overload behavior
The current bool overload has broken semantics, because it considers the version "0" to be false. The bool overload used to have sane semantics (equivalent to is_valid()) before commit 5b9f353b2940de751df47036608afbe71992d622, but there it got changed to return the stringified version if it was valid, or undef otherwise, to fix a problem within dpkg-shlibdeps, instead of properly fixing the local-only problem in the tool. This makes the overload hard to use, and broke existing callers from external projects. We will emit a warning until dpkg 1.20.x to notify of the semantic change in case there is code relying on the broken semantics. For fixed code the warning can then be quiesced with: no warnings qw(Dpkg::Version::semantic_change::overload::bool); Closes: #895004
Diffstat (limited to 'scripts/t')
-rw-r--r--scripts/t/Dpkg_Version.t17
1 files changed, 8 insertions, 9 deletions
diff --git a/scripts/t/Dpkg_Version.t b/scripts/t/Dpkg_Version.t
index 78db7aead..17e9b4b9e 100644
--- a/scripts/t/Dpkg_Version.t
+++ b/scripts/t/Dpkg_Version.t
@@ -20,6 +20,7 @@ use Test::More;
use Dpkg::ErrorHandling;
use Dpkg::IPC;
+use Dpkg::Version;
report_options(quiet_warnings => 1);
@@ -30,7 +31,7 @@ my @ops = ('<', '<<', 'lt',
'>=', 'ge',
'>', '>>', 'gt');
-plan tests => scalar(@tests) * (3 * scalar(@ops) + 4) + 30;
+plan tests => scalar(@tests) * (3 * scalar(@ops) + 4) + 27;
sub dpkg_vercmp {
my ($a, $cmp, $b) = @_;
@@ -57,8 +58,6 @@ sub obj_vercmp {
return $a gt $b if $cmp eq 'gt';
}
-use_ok('Dpkg::Version');
-
my $truth = {
'-1' => {
'<<' => 1, 'lt' => 1,
@@ -83,6 +82,12 @@ my $truth = {
},
};
+# XXX: Some of the tests check the bool overload, which currently emits
+# the semantic_change warning. Disable it until we stop emitting the
+# warning in dpkg 1.20.x.
+## no critic (TestingAndDebugging::ProhibitNoWarnings)
+no warnings(qw(Dpkg::Version::semantic_change::overload::bool));
+
# Handling of empty/invalid versions
my $empty = Dpkg::Version->new('');
ok($empty eq '', "Dpkg::Version->new('') eq ''");
@@ -128,12 +133,6 @@ ok(!$ver->is_native(), 'upstream version w/ revision is not native');
$ver = Dpkg::Version->new('1.0-1.0-1');
ok(!$ver->is_native(), 'upstream version w/ dash and revision is not native');
-# Other tests
-$ver = Dpkg::Version->new('1.2.3-4');
-is($ver || 'default', '1.2.3-4', 'bool eval returns string representation');
-$ver = Dpkg::Version->new('0');
-is($ver || 'default', 'default', 'bool eval of version 0 is still false...');
-
# Comparisons
foreach my $case (@tests) {
my ($a, $b, $res) = split ' ', $case;