summaryrefslogtreecommitdiff
path: root/ext/Test-Harness/t/utils.t
blob: d60c8a2939e71416c47692eceda2f1f60c6ed6d4 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/perl -w

BEGIN {
    chdir 't' and @INC = '../lib' if $ENV{PERL_CORE};
}

use strict;
use lib 't/lib';

use TAP::Parser::Utils qw( split_shell );
use Test::More;

my @schedule = (
    {   name => 'Bare words',
        in   => 'bare words are here',
        out  => [ 'bare', 'words', 'are', 'here' ],
    },
    {   name => 'Single quotes',
        in   => "'bare' 'words' 'are' 'here'",
        out  => [ 'bare', 'words', 'are', 'here' ],
    },
    {   name => 'Double quotes',
        in   => '"bare" "words" "are" "here"',
        out  => [ 'bare', 'words', 'are', 'here' ],
    },
    {   name => 'Escapes',
        in   => '\  "ba\"re" \'wo\\\'rds\' \\\\"are" "here"',
        out  => [ ' ', 'ba"re', "wo'rds", '\\are', 'here' ],
    },
    {   name => 'Flag',
        in   => '-e "system(shift)"',
        out  => [ '-e', 'system(shift)' ],
    },
    {   name => 'Nada',
        in   => undef,
        out  => [],
    },
    {   name => 'Nada II',
        in   => '',
        out  => [],
    },
    {   name => 'Zero',
        in   => 0,
        out  => ['0'],
    },
    {   name => 'Empty',
        in   => '""',
        out  => [''],
    },
    {   name => 'Empty II',
        in   => "''",
        out  => [''],
    },
);

plan tests => 1 * @schedule;

for my $test (@schedule) {
    my $name = $test->{name};
    my @got  = split_shell( $test->{in} );
    unless ( is_deeply \@got, $test->{out}, "$name: parse OK" ) {
        use Data::Dumper;
        diag( Dumper( { want => $test->{out}, got => \@got } ) );
    }
}