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