1#!/usr/bin/perl -w 2 3BEGIN { 4 unshift @INC, 't/lib'; 5} 6 7chdir 't'; 8 9use Config; 10use MakeMaker::Test::Utils; 11use Test::More tests => 16; 12use File::Spec; 13 14my $TB = Test::More->builder; 15my $perl = which_perl; 16 17BEGIN { use_ok('ExtUtils::MM') } 18 19my $mm = bless { NAME => "Foo", MAKE => $Config{make} }, 'MM'; 20isa_ok($mm, 'ExtUtils::MakeMaker'); 21isa_ok($mm, 'ExtUtils::MM_Any'); 22 23 24sub try_oneliner { 25 my($code, $switches, $expect, $name) = @_; 26 my $cmd = $mm->oneliner($code, $switches); 27 $cmd =~ s{\$\(ABSPERLRUN\)}{$perl}; 28 29 # VMS likes to put newlines at the end of commands if there isn't 30 # one already. 31 $expect =~ s/([^\n])\z/$1\n/ if $^O eq 'VMS'; 32 33 $TB->is_eq(scalar `$cmd`, $expect, $name) || $TB->diag("oneliner:\n$cmd"); 34} 35 36# Lets see how it deals with quotes. 37try_oneliner(q{print "foo'o", ' bar"ar'}, [], q{foo'o bar"ar}, 'quotes'); 38 39# How about dollar signs? 40try_oneliner(q{$PATH = 'foo'; print $PATH},[], q{foo}, 'dollar signs' ); 41 42# switches? 43try_oneliner(q{print 'foo'}, ['-l'], "foo\n", 'switches' ); 44 45# some DOS-specific things 46try_oneliner(q{print " \" "}, [], q{ " }, 'single quote' ); 47try_oneliner(q{print " < \" "}, [], q{ < " }, 'bracket, then quote' ); 48try_oneliner(q{print " \" < "}, [], q{ " < }, 'quote, then bracket' ); 49try_oneliner(q{print " < \"\" < \" < \" < "}, [], q{ < "" < " < " < }, 'quotes and brackets mixed' ); 50try_oneliner(q{print " < \" | \" < | \" < \" < "}, [], q{ < " | " < | " < " < }, 'brackets, pipes and quotes' ); 51 52# some examples from http://www.autohotkey.net/~deleyd/parameters/parameters.htm#CPP 53try_oneliner(q{print q[ &<>^|()@ ! ]}, [], q{ &<>^|()@ ! }, 'example 8.1' ); 54try_oneliner(q{print q[ &<>^|@()!"&<>^|@()! ]}, [], q{ &<>^|@()!"&<>^|@()! }, 'example 8.2' ); 55try_oneliner(q{print q[ "&<>^|@() !"&<>^|@() !" ]}, [], q{ "&<>^|@() !"&<>^|@() !" }, 'example 8.3' ); 56try_oneliner(q{print q[ "C:\TEST A\" ]}, [], q{ "C:\TEST A\" }, 'example 8.4' ); 57try_oneliner(q{print q[ "C:\TEST %&^ A\" ]}, [], q{ "C:\TEST %&^ A\" }, 'example 8.5' ); 58 59# XXX gotta rethink the newline test. The Makefile does newline 60# escaping, then the shell. 61 62