4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
9 { q{one t'wo th'ree f"o\"ur " "five" } => [ 'one', 'two three', 'fo"ur ', 'five' ] },
10 { q{ foo bar } => [ 'foo', 'bar' ] },
15 { 'a" "b\\c" "d' => [ 'a b\c d' ] },
16 { '"a b\\c d"' => [ 'a b\c d' ] },
17 { '"a b"\\"c d"' => [ 'a b"c', 'd' ] },
18 { '"a b"\\\\"c d"' => [ 'a b\c d' ] },
19 { '"a"\\"b" "a\\"b"' => [ 'a"b a"b' ] },
20 { '"a"\\\\"b" "a\\\\"b"' => [ 'a\b', 'a\b' ] },
21 { '"a"\\"b a\\"b"' => [ 'a"b', 'a"b' ] },
22 { 'a"\\"b" "a\\"b' => [ 'a"b', 'a"b' ] },
23 { 'a"\\"b" "a\\"b' => [ 'a"b', 'a"b' ] },
24 { 'a b' => [ 'a', 'b' ] },
25 { 'a"\\"b a\\"b' => [ 'a"b a"b' ] },
26 { '"a""b" "a"b"' => [ 'a"b ab' ] },
27 { '\\"a\\"' => [ '"a"' ] },
28 { '"a"" "b"' => [ 'a"', 'b' ] },
29 { 'a"b' => [ 'ab' ] },
30 { 'a""b' => [ 'ab' ] },
31 { 'a"""b' => [ 'a"b' ] },
32 { 'a""""b' => [ 'a"b' ] },
33 { 'a"""""b' => [ 'a"b' ] },
34 { 'a""""""b' => [ 'a""b' ] },
35 { '"a"b"' => [ 'ab' ] },
36 { '"a""b"' => [ 'a"b' ] },
37 { '"a"""b"' => [ 'a"b' ] },
38 { '"a""""b"' => [ 'a"b' ] },
39 { '"a"""""b"' => [ 'a""b' ] },
40 { '"a""""""b"' => [ 'a""b' ] },
46 { '""a b' => [ 'a', 'b' ] },
48 { 'a"" b' => [ 'a', 'b' ] },
49 { '"" a' => [ '', 'a' ] },
50 { 'a ""' => [ 'a', '' ] },
51 { 'a "" b' => [ 'a', '', 'b' ] },
52 { 'a " " b' => [ 'a', ' ', 'b' ] },
53 { 'a " b " c' => [ 'a', ' b ', 'c' ] },
56 plan tests => 10 + 2*@unix_splits + 2*@win_splits;
58 #########################
63 # Should always return an array unscathed
64 foreach my $platform ('', '::Platform::Unix', '::Platform::Windows') {
65 my $pkg = "Module::Build$platform";
66 my @result = $pkg->split_like_shell(['foo', 'bar', 'baz']);
67 is @result, 3, "Split using $pkg";
68 is "@result", "foo bar baz", "Split using $pkg";
71 use Module::Build::Platform::Unix;
72 foreach my $test (@unix_splits) {
73 do_split_tests('Module::Build::Platform::Unix', $test);
76 use Module::Build::Platform::Windows;
77 foreach my $test (@win_splits) {
78 do_split_tests('Module::Build::Platform::Windows', $test);
83 # Make sure read_args() functions properly as a class method
84 my @args = qw(foo=bar --food bard --foods=bards);
85 my ($args) = Module::Build->read_args(@args);
86 is_deeply($args, {foo => 'bar', food => 'bard', foods => 'bards', ARGV => []});
90 # Make sure data can make a round-trip through unparse_args() and read_args()
91 my %args = (foo => 'bar', food => 'bard', config => {a => 1, b => 2}, ARGV => []);
92 my ($args) = Module::Build->read_args( Module::Build->unparse_args(\%args) );
93 is_deeply($args, \%args);
97 # Make sure run_perl_script() propagates @INC
98 local @INC = ('whosiewhatzit', @INC);
99 my $output = stdout_of( sub { Module::Build->run_perl_script('', ['-le', 'print for @INC']) } );
100 like $output, qr{^whosiewhatzit}m;
103 ##################################################################
105 my ($package, $test) = @_;
107 my ($string, $expected) = %$test;
108 my @result = $package->split_like_shell($string);
109 is( 0 + grep( !defined(), @result ), # all defined
111 "'$string' result all defined" );
112 is_deeply(\@result, $expected);