File: _subtest_selection.t

package info (click to toggle)
libtest-expander-perl 2.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 324 kB
  • sloc: perl: 457; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use strict;
use warnings
  FATAL    => qw( all ),
  NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized );

use Test2::V0 -target => 'Test::Expander';

use Test::Expander::Constants qw( $FMT_INVALID_SUBTEST_NUMBER );

plan( 4 );

Test2::Tools::Subtest::subtest_streamed 'enforced usage of subtest_streamed for better test coverage' => sub {
  plan( 1 );
  local @ARGV = ( '--subtest_number' => '1/0/' );
  my $expected = sprintf( $FMT_INVALID_SUBTEST_NUMBER, '1/0/' );
  like( dies { Test::Expander::_subtest_selection() }, qr/$expected/, 'choose subtest by invalid number' );
};

{
  local @ARGV = ( '--subtest_name' => 'valid RegEx' );
  is( Test::Expander::_subtest_selection(), undef, 'choose subtest by valid RegEx' );
}

{
  local @ARGV = ( '--subtest_name' => '[invalid RegEx' );
  is( Test::Expander::_subtest_selection(), undef, 'choose subtest by invalid RegEx' );
}

{
  local @ARGV = ( '--subtest_number' => '1/0/2' );
  is( Test::Expander::_subtest_selection(), undef, 'choose subtest by valid number' );
}