Skip to content

Commit

Permalink
Convert old tests to use Test2
Browse files Browse the repository at this point in the history
  • Loading branch information
DrHyde committed Apr 22, 2024
1 parent 8fbfc2d commit 4e09d72
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 55 deletions.
6 changes: 0 additions & 6 deletions Makefile.PL
Expand Up @@ -18,12 +18,6 @@ WriteMakefile(
'Capture::Tiny' => 0,
'Carp' => 0,
'if' => 0,

# for Scalar::Type tests, these will eventually get ported to Test2
'Test::Exception' => 0,
'Test::More' => 0.96,

# for Test2::Tools::Type, earlier probably works too
'Test2::API' => 1.302198,
'Test2::V0' => 0.000159,
},
Expand Down
20 changes: 7 additions & 13 deletions t/bool.t
@@ -1,8 +1,4 @@
use strict;
use warnings;

use Test::More;
use Test::Exception;
use Test2::V0;

use Config;

Expand All @@ -25,11 +21,10 @@ if(Scalar::Type::bool_supported) {
ok(!is_bool(''), "and it says no for plain old '' (otherwise indistinguishable from (1 == 0))");
} else {
# the :all above only included is_bool if bool_supported so we need to use the full name here
throws_ok(
sub { Scalar::Type::is_bool(1 == 1) },
like
dies { Scalar::Type::is_bool(1 == 1) },
qr/::is_bool not supported on your perl/,
"is_bool carks it on Ye Olde Perle $]"
);
"is_bool carks it on Ye Olde Perle $]";
is(
type(1 == 1),
'INTEGER',
Expand All @@ -42,11 +37,10 @@ if(Scalar::Type::bool_supported) {
);

# finally, test that we can't explicitly import is_bool on Ye Olde Perle
throws_ok(
sub { Scalar::Type->import('is_bool') },
like
dies { Scalar::Type->import('is_bool') },
qr/is_bool/,
"can't import is_bool on Ye Olde Perle $]"
);
"can't import is_bool on Ye Olde Perle $]";
}

done_testing;
4 changes: 1 addition & 3 deletions t/pod-coverage.t
@@ -1,7 +1,5 @@
use strict;
use warnings;
use Test2::V0;

use Test::More;
eval "use Test::Pod::Coverage 1.08";
plan skip_all => "Test::Pod::Coverage 1.08 required for testing POD coverage" if $@;
foreach my $module (grep {
Expand Down
4 changes: 1 addition & 3 deletions t/pod.t
@@ -1,7 +1,5 @@
use strict;
use warnings;
use Test2::V0;

use Test::More;
eval "use Test::Pod 1.18";
plan skip_all => "Test::Pod 1.18 required for testing POD" if $@;
all_pod_files_ok(grep { $_ !~ m{Number/Phone/UK/Data.pm$} } all_pod_files());
Expand Down
20 changes: 7 additions & 13 deletions t/sizeof.t
@@ -1,8 +1,4 @@
use strict;
use warnings;

use Test::More;
use Test::Exception;
use Test2::V0;

use Config;

Expand All @@ -17,16 +13,14 @@ subtest "sizeof(number)" => sub {
};

subtest "sizeof(whatever)" => sub {
throws_ok(
sub { sizeof() },
like
dies { sizeof() },
qr{::sizeof requires an argument at t/sizeof.t line},
"sizeof() requires an argument"
);
throws_ok(
sub { sizeof("banana") },
"sizeof() requires an argument";
like
dies { sizeof("banana") },
qr{::sizeof: 'banana' isn't numeric: SCALAR},
"sizeof()'s arg must be plausibly numeric"
);
"sizeof()'s arg must be plausibly numeric";
};

done_testing;
28 changes: 11 additions & 17 deletions t/types.t
@@ -1,9 +1,6 @@
use strict;
use warnings;
no warnings 'void';
use Test2::V0;

use Test::More;
use Test::Exception;
no warnings 'void';

use Scalar::Type qw(is_* type);
use B;
Expand Down Expand Up @@ -190,20 +187,17 @@ subtest "type returns the documented values for non-reference types" => sub {
is(type(undef), 'UNDEF', 'undef is of type UNDEF');
};

throws_ok(
sub { type() },
like
dies { type() },
qr{::type requires an argument at t/types.t line},
"type() requires an argument"
);
throws_ok(
sub { is_number() },
"type() requires an argument";
like
dies { is_number() },
qr{::is_number requires an argument at t/types.t line},
"is_number() requires an argument"
);
throws_ok(
sub { is_integer() },
"is_number() requires an argument";
like
dies { is_integer() },
qr{::is_integer requires an argument at t/types.t line},
"is_integer() requires an argument"
);
"is_integer() requires an argument";

done_testing;

0 comments on commit 4e09d72

Please sign in to comment.