diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 71fa66e..0183894 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v4 - uses: shogo82148/actions-setup-perl@v1 with: - perl-version: 5.32 + perl-version: 5.38 - name: Run with coverage checking env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/lib/Test2/Tools/Type.pm b/lib/Test2/Tools/Type.pm index 6eb8447..ae227a3 100644 --- a/lib/Test2/Tools/Type.pm +++ b/lib/Test2/Tools/Type.pm @@ -31,7 +31,7 @@ sub import { if(grep { $_ eq 'show_types' } @_) { print "Supported types:\n"; print " ".substr($_, 3)."\n" foreach(sort grep { /^is_/ } @EXPORT); - exit; + return; } } goto &Exporter::import; diff --git a/t/test2-tools-type.t b/t/test2-tools-type.t index b366160..025ef1b 100644 --- a/t/test2-tools-type.t +++ b/t/test2-tools-type.t @@ -1,5 +1,5 @@ use Test2::V0; -use Test2::Tools::Type; +use Test2::Tools::Type; # NB no :extras! use Test2::API qw/intercept/; use Capture::Tiny qw(capture); @@ -10,7 +10,31 @@ ok( "extra functions aren't available unless asked for" ); -Test2::Tools::Type->import(':extras'); +subtest "show supported types" => sub { + my $types_supported = capture { + Test2::Tools::Type->import(qw(show_types)) + }; + like + $types_supported, + match(qr/\n number\n/), + "default types"; + like + $types_supported, + !match(qr/\n positive\n/), + "default types doesn't include the extras"; + + # this does *not* make extras available for the test of the tests + # because `show_types` aborts import() before it can do anything + $types_supported = capture { + Test2::Tools::Type->import(qw(show_types :extras)) + }; + like + $types_supported, + match(qr/\n positive\n/), + ":extras makes extras visible"; +}; + +Test2::Tools::Type->import(qw(:extras)); subtest "is_* tests" => sub { my $events = intercept { @@ -367,28 +391,4 @@ subtest "checks don't mess with types" => sub { ); }; -subtest "show supported types" => sub { - my $types_supported = capture { system( - $Config{perlpath}, (map { "-I$_" } (@INC)), - qw(-MTest2::Tools::Type=show_types -e0) - ) }; - like - $types_supported, - match(qr/\n number\n/), - "default types"; - like - $types_supported, - !match(qr/\n positive\n/), - "default types doesn't include the extras"; - - $types_supported = capture { system( - $Config{perlpath}, (map { "-I$_" } (@INC)), - '-MTest2::Tools::Type=show_types,:extras' - ) }; - like - $types_supported, - match(qr/\n positive\n/), - ":extras makes extras available"; -}; - done_testing;