1b39c5158Smillert#!/usr/bin/perl -w 2b39c5158Smillert 3*eac174f2Safresh1use strict; 4*eac174f2Safresh1use warnings; 5*eac174f2Safresh1 6b39c5158SmillertBEGIN { 7b39c5158Smillert unshift @INC, 't/lib'; 8b39c5158Smillert} 9b39c5158Smillert 10b39c5158Smillertchdir 't'; 11b39c5158Smillert 12898184e3Ssthenuse Config; 13b39c5158Smillertuse MakeMaker::Test::Utils; 14898184e3Ssthenuse Test::More tests => 16; 15b39c5158Smillertuse File::Spec; 16b39c5158Smillert 17b39c5158Smillertmy $TB = Test::More->builder; 18b8851fccSafresh1my $perl = which_perl; 19b39c5158Smillert 20b39c5158SmillertBEGIN { use_ok('ExtUtils::MM') } 21b39c5158Smillert 22898184e3Ssthenmy $mm = bless { NAME => "Foo", MAKE => $Config{make} }, 'MM'; 23b39c5158Smillertisa_ok($mm, 'ExtUtils::MakeMaker'); 24b39c5158Smillertisa_ok($mm, 'ExtUtils::MM_Any'); 25b39c5158Smillert 26b39c5158Smillert 27b39c5158Smillertsub try_oneliner { 28b39c5158Smillert my($code, $switches, $expect, $name) = @_; 29b39c5158Smillert my $cmd = $mm->oneliner($code, $switches); 30b8851fccSafresh1 $cmd =~ s{\$\(ABSPERLRUN\)}{$perl}; 31b39c5158Smillert 32b39c5158Smillert # VMS likes to put newlines at the end of commands if there isn't 33b39c5158Smillert # one already. 34b39c5158Smillert $expect =~ s/([^\n])\z/$1\n/ if $^O eq 'VMS'; 35b39c5158Smillert 36b39c5158Smillert $TB->is_eq(scalar `$cmd`, $expect, $name) || $TB->diag("oneliner:\n$cmd"); 37b39c5158Smillert} 38b39c5158Smillert 39b39c5158Smillert# Lets see how it deals with quotes. 40b39c5158Smillerttry_oneliner(q{print "foo'o", ' bar"ar'}, [], q{foo'o bar"ar}, 'quotes'); 41b39c5158Smillert 42b39c5158Smillert# How about dollar signs? 43b39c5158Smillerttry_oneliner(q{$PATH = 'foo'; print $PATH},[], q{foo}, 'dollar signs' ); 44b39c5158Smillert 45b39c5158Smillert# switches? 46b39c5158Smillerttry_oneliner(q{print 'foo'}, ['-l'], "foo\n", 'switches' ); 47b39c5158Smillert 48898184e3Ssthen# some DOS-specific things 49898184e3Ssthentry_oneliner(q{print " \" "}, [], q{ " }, 'single quote' ); 50898184e3Ssthentry_oneliner(q{print " < \" "}, [], q{ < " }, 'bracket, then quote' ); 51898184e3Ssthentry_oneliner(q{print " \" < "}, [], q{ " < }, 'quote, then bracket' ); 52898184e3Ssthentry_oneliner(q{print " < \"\" < \" < \" < "}, [], q{ < "" < " < " < }, 'quotes and brackets mixed' ); 53898184e3Ssthentry_oneliner(q{print " < \" | \" < | \" < \" < "}, [], q{ < " | " < | " < " < }, 'brackets, pipes and quotes' ); 54898184e3Ssthen 55898184e3Ssthen# some examples from http://www.autohotkey.net/~deleyd/parameters/parameters.htm#CPP 56898184e3Ssthentry_oneliner(q{print q[ &<>^|()@ ! ]}, [], q{ &<>^|()@ ! }, 'example 8.1' ); 57898184e3Ssthentry_oneliner(q{print q[ &<>^|@()!"&<>^|@()! ]}, [], q{ &<>^|@()!"&<>^|@()! }, 'example 8.2' ); 58898184e3Ssthentry_oneliner(q{print q[ "&<>^|@() !"&<>^|@() !" ]}, [], q{ "&<>^|@() !"&<>^|@() !" }, 'example 8.3' ); 59898184e3Ssthentry_oneliner(q{print q[ "C:\TEST A\" ]}, [], q{ "C:\TEST A\" }, 'example 8.4' ); 60898184e3Ssthentry_oneliner(q{print q[ "C:\TEST %&^ A\" ]}, [], q{ "C:\TEST %&^ A\" }, 'example 8.5' ); 61898184e3Ssthen 62b39c5158Smillert# XXX gotta rethink the newline test. The Makefile does newline 63b39c5158Smillert# escaping, then the shell. 64b39c5158Smillert 65