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