summaryrefslogtreecommitdiff
path: root/cpan/version
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2013-07-16 22:05:57 -0600
committerKarl Williamson <public@khwilliamson.com>2013-07-19 10:35:14 -0600
commit3fca3d61b552b8da4cb82e43e9eac517631ef737 (patch)
treeea6b89b1ec30b11b25d8d5d77512643398c7c9ea /cpan/version
parent1078c6a2c81c4b65a2bdfe9f9778a03e3fb57bec (diff)
downloadperl-3fca3d61b552b8da4cb82e43e9eac517631ef737.tar.gz
cpan/version/t/07locale.t: Actually test what is claimed
Commit b127e37e51c21b0a36755dcd19811be931a03d83 wrongly changed two tests, and failed to change a third. One of the two ended up doing: ok ("$ver eq '1,23'", ...); That's always going to succeed as ok() doesn't do an eval; it just looks at the result of the expression, which in this case was a non-empty string. The second test was changed from an 'eq' to '=='. It had this diff: - is ($v, "1.23", "Locale doesn't apply to version objects"); + ok ($v == "1.23", "Locale doesn't apply to version objects"); (The code for is() does an 'eq'.) The is() call is made from within the scope of a "use locale" in which the decimal point character is a comma, but version objects are supposed to always use a dot, regardless of the locale. The == will numify the operands, potentially throwing away the locale's decimal point character. Therefore the test should use an 'eq'. Before these changes, the two tests also didn't do what they purported (and hence the motivation for the changes). The tests previously used 'is()', which is defined in a different file which is outside the locale scope, so that the scalars ($v and $ver) there should have a dot even if they have a comma within locale scope, and hence doing an is() would not catch the bug being tested against. Hence the third test (overlooked in the earlier commit) remained wrong until now.
Diffstat (limited to 'cpan/version')
-rw-r--r--cpan/version/t/07locale.t9
1 files changed, 6 insertions, 3 deletions
diff --git a/cpan/version/t/07locale.t b/cpan/version/t/07locale.t
index 784bc116b7..fe8e0e51db 100644
--- a/cpan/version/t/07locale.t
+++ b/cpan/version/t/07locale.t
@@ -27,7 +27,10 @@ SKIP: {
my $ver = 1.23; # has to be floating point number
my $loc;
my $orig_loc = setlocale(LC_NUMERIC);
- is ($ver, '1.23', 'Not using locale yet');
+ ok ($ver eq "1.23", 'Not using locale yet'); # Don't use is(),
+ # because have to
+ # evaluate in current
+ # scope
while (<DATA>) {
chomp;
$loc = setlocale( LC_ALL, $_);
@@ -39,11 +42,11 @@ SKIP: {
diag ("Testing locale handling with $loc") unless $ENV{PERL_CORE};
setlocale(LC_NUMERIC, $loc);
- ok ("$ver eq '1,23'", "Using locale: $loc");
+ ok ($ver eq "1,23", "Using locale: $loc");
$v = version->new($ver);
unlike($warning, qr/Version string '1,23' contains invalid data/,
"Process locale-dependent floating point");
- ok ($v == "1.23", "Locale doesn't apply to version objects");
+ ok ($v eq "1.23", "Locale doesn't apply to version objects");
ok ($v == $ver, "Comparison to locale floating point");
{