Skip to content

Commit

Permalink
Merge pull request #1015 from book/fix-version-string-comparisons
Browse files Browse the repository at this point in the history
fix string comparisons with $] to use numeric comparison instead
  • Loading branch information
exodist authored Dec 19, 2024
2 parents 4479a51 + 5ba7269 commit b486145
Show file tree
Hide file tree
Showing 18 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/Test2/API.pm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ sub CLONE {

BEGIN {
no warnings 'once';
if($] ge '5.014' || $ENV{T2_CHECK_DEPTH} || $Test2::API::DO_DEPTH_CHECK) {
if("$]" >= 5.014 || $ENV{T2_CHECK_DEPTH} || $Test2::API::DO_DEPTH_CHECK) {
*DO_DEPTH_CHECK = sub() { 1 };
}
else {
Expand Down
2 changes: 1 addition & 1 deletion lib/Test2/Formatter/TAP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ sub _open_handles {
sub encoding {
my $self = shift;

if ($] ge "5.007003" and @_) {
if ("$]" >= 5.007003 and @_) {
my ($enc) = @_;
my $handles = $self->{+HANDLES};

Expand Down
4 changes: 2 additions & 2 deletions lib/Test2/Tools/Tiny.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use strict;
use warnings;

BEGIN {
if ($] lt "5.008") {
if ("$]" < 5.008) {
require Test::Builder::IO::Scalar;
}
}
Expand Down Expand Up @@ -260,7 +260,7 @@ sub capture(&) {

($ok, $e) = try {
# Scalar refs as filehandles were added in 5.8.
if ($] ge "5.008") {
if ("$]" >= 5.008) {
open($out_fh, '>', \$out) or die "Failed to open a temporary STDOUT: $!";
open($err_fh, '>', \$err) or die "Failed to open a temporary STDERR: $!";
}
Expand Down
2 changes: 1 addition & 1 deletion t/HashBase.t
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ is($pkg->do_it, 'const', "worked as expected");
}
ok(!$pkg->FOO, "overrode const sub");
{
local $TODO = "known to fail on $]" if $] le "5.006002";
local $TODO = "known to fail on $]" if "$]" <= 5.006002;
is($pkg->do_it, 'const', "worked as expected, const was constant");
}

Expand Down
2 changes: 1 addition & 1 deletion t/Legacy/Regression/736_use_ok.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sub capture(&) {
}

{
local $TODO = "known to fail on $]" if $] le "5.006002";
local $TODO = "known to fail on $]" if "$]" <= 5.006002;
my $file = __FILE__;
my $line = __LINE__ + 4;
like(
Expand Down
2 changes: 1 addition & 1 deletion t/Legacy/overload_threads.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BEGIN {

use Test::More;

plan skip_all => "known to crash on $]" if $] le "5.006002";
plan skip_all => "known to crash on $]" if "$]" <= 5.006002;

plan tests => 5;

Expand Down
2 changes: 1 addition & 1 deletion t/Legacy_And_Test2/preload_diag_note.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use strict;
use warnings;

if ($] lt "5.008") {
if ("$]" < 5.008) {
print "1..0 # SKIP Test cannot run on perls below 5.8.0\n";
exit 0;
}
Expand Down
2 changes: 1 addition & 1 deletion t/Test2/behavior/init_croak.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BEGIN {
}
}

skip_all("known to fail on $]") if $] le "5.006002";
skip_all("known to fail on $]") if "$]" <= 5.006002;

$@ = "";
my ($file, $line) = (__FILE__, __LINE__ + 1);
Expand Down
2 changes: 1 addition & 1 deletion t/Test2/behavior/nested_context_exception.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use Test2::Tools::Tiny;

use Test2::API qw/context/;

skip_all("known to fail on $]") if $] le "5.006002";
skip_all("known to fail on $]") if "$]" <= 5.006002;

sub outer {
my $code = shift;
Expand Down
2 changes: 1 addition & 1 deletion t/Test2/modules/API.t
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ like(
"got warning about adding driver too late"
);
};
if ($] le "5.006002") {
if ("$]" <= 5.006002) {
todo("TODO known to fail on $]", $sub1);
} else {
$sub1->();
Expand Down
2 changes: 1 addition & 1 deletion t/Test2/modules/API/Breakage.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use strict;
use warnings;

if ($] lt "5.008") {
if ("$]" < 5.008) {
print "1..0 # SKIP Test cannot run on perls below 5.8.0 because local doesn't work on hash keys.\n";
exit 0;
}
Expand Down
6 changes: 3 additions & 3 deletions t/Test2/modules/API/Instance.t
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ if (CAN_REALLY_FORK) {
like($warnings[0], qr/Process .* did not exit cleanly \(wstat: \S+, exit: 0, sig: 15\)/, "Warn about exit");
}

if (CAN_THREAD && $] ge '5.010') {
if (CAN_THREAD && "$]" >= 5.010) {
require threads;
my $one = $CLASS->new;

Expand Down Expand Up @@ -297,7 +297,7 @@ if (CAN_THREAD && $] ge '5.010') {
}

SKIP: {
last SKIP if $] lt "5.008";
last SKIP if "$]" < 5.008;
my $one = $CLASS->new;
my $stderr = "";
{
Expand Down Expand Up @@ -326,7 +326,7 @@ This is not a supported configuration, you will have problems.
}

SKIP: {
last SKIP if $] lt "5.008";
last SKIP if "$]" < 5.008;
require Test2::API::Breakage;
no warnings qw/redefine once/;
my $ran = 0;
Expand Down
2 changes: 1 addition & 1 deletion t/Test2/modules/Hub.t
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ tests IPC => sub {
}
}

if (CAN_THREAD && $] ge '5.010') {
if (CAN_THREAD && "$]" >= 5.010) {
require threads;
my $thr = threads->new(sub { $do_send->() });
$thr->join;
Expand Down
2 changes: 1 addition & 1 deletion t/Test2/modules/IPC/Driver.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ for my $meth (qw/send cull add_hub drop_hub waiting is_viable/) {
}

SKIP: {
last SKIP if $] lt "5.008";
last SKIP if "$]" < 5.008;
tests abort => sub {
my $one = Test2::IPC::Driver->new(no_fatal => 1);
my ($err, $out) = ("", "");
Expand Down
2 changes: 1 addition & 1 deletion t/Test2/modules/IPC/Driver/Files.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use List::Util qw/shuffle/;
use strict;
use warnings;

if ($] lt "5.008") {
if ("$]" < 5.008) {
print "1..0 # SKIP Test cannot run on perls below 5.8.0\n";
exit 0;
}
Expand Down
4 changes: 2 additions & 2 deletions t/Test2/modules/Util.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use Test2::Util qw/
/;

BEGIN {
if ($] lt "5.008") {
if ("$]" < 5.008) {
require Test::Builder::IO::Scalar;
}
}
Expand Down Expand Up @@ -83,7 +83,7 @@ close($io);

my $fh;
my $out = '';
if ($] ge "5.008") {
if ("$]" >= 5.008) {
open($fh, '>', \$out) or die "Could not open filehandle";
} else {
$fh = Test::Builder::IO::Scalar->new(\$out) or die "Could not open filehandle";
Expand Down
2 changes: 1 addition & 1 deletion t/Test2/regression/ipc_files_abort_exit.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Test2::Util qw/CAN_REALLY_FORK/;
BEGIN {
skip_all "Set AUTHOR_TESTING to run this test" unless $ENV{AUTHOR_TESTING};
skip_all "System cannot fork" unless CAN_REALLY_FORK;
skip_all "known to fail on $]" if $] le "5.006002";
skip_all "known to fail on $]" if "$]" <= 5.006002;
}

use IPC::Open3 qw/open3/;
Expand Down
2 changes: 1 addition & 1 deletion t/modules/Require/Perl.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use Test2::Bundle::Extended -target => 'Test2::Require::Perl';

is($CLASS->skip('v5.6'), undef, "will not skip");
is($CLASS->skip('v10.10'), 'Perl v10.10.0 required', "will skip");
is($CLASS->skip('v100.100'), 'Perl v100.100.0 required', "will skip"); # fix this before 2054

done_testing;

0 comments on commit b486145

Please sign in to comment.