Debian lenny version packages
[pkg-perl] / deb-src / libtest-harness-perl / libtest-harness-perl-3.12 / t / utils.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     chdir 't' and @INC = '../lib' if $ENV{PERL_CORE};
5 }
6
7 use strict;
8 use lib 't/lib';
9
10 use TAP::Parser::Utils qw( split_shell );
11 use Test::More;
12
13 my @schedule = (
14     {   name => 'Bare words',
15         in   => 'bare words are here',
16         out  => [ 'bare', 'words', 'are', 'here' ],
17     },
18     {   name => 'Single quotes',
19         in   => "'bare' 'words' 'are' 'here'",
20         out  => [ 'bare', 'words', 'are', 'here' ],
21     },
22     {   name => 'Double quotes',
23         in   => '"bare" "words" "are" "here"',
24         out  => [ 'bare', 'words', 'are', 'here' ],
25     },
26     {   name => 'Escapes',
27         in   => '\  "ba\"re" \'wo\\\'rds\' \\\\"are" "here"',
28         out  => [ ' ', 'ba"re', "wo'rds", '\\are', 'here' ],
29     },
30     {   name => 'Flag',
31         in   => '-e "system(shift)"',
32         out  => [ '-e', 'system(shift)' ],
33     },
34     {   name => 'Nada',
35         in   => undef,
36         out  => [],
37     },
38     {   name => 'Nada II',
39         in   => '',
40         out  => [],
41     },
42     {   name => 'Zero',
43         in   => 0,
44         out  => ['0'],
45     },
46     {   name => 'Empty',
47         in   => '""',
48         out  => [''],
49     },
50     {   name => 'Empty II',
51         in   => "''",
52         out  => [''],
53     },
54 );
55
56 plan tests => 1 * @schedule;
57
58 for my $test (@schedule) {
59     my $name = $test->{name};
60     my @got  = split_shell( $test->{in} );
61     unless ( is_deeply \@got, $test->{out}, "$name: parse OK" ) {
62         use Data::Dumper;
63         diag( Dumper( { want => $test->{out}, got => \@got } ) );
64     }
65 }