Fix a2p manpage (from Debian)
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / oneliner.t
CommitLineData
479d2113 1#!/usr/bin/perl -w
2
3BEGIN {
4 if( $ENV{PERL_CORE} ) {
5 chdir 't' if -d 't';
6 @INC = ('../lib', 'lib');
7 }
8 else {
9 unshift @INC, 't/lib';
10 }
11}
12
13chdir 't';
14
15use MakeMaker::Test::Utils;
16use Test::More tests => 6;
17use File::Spec;
18
19my $TB = Test::More->builder;
20
21BEGIN { use_ok('ExtUtils::MM') }
22
23my $mm = bless { NAME => "Foo" }, 'MM';
24isa_ok($mm, 'ExtUtils::MakeMaker');
25isa_ok($mm, 'ExtUtils::MM_Any');
26
27
28sub try_oneliner {
29 my($code, $switches, $expect, $name) = @_;
30 my $cmd = $mm->oneliner($code, $switches);
5dca256e 31 $cmd =~ s{\$\(ABSPERLRUN\)}{$^X};
479d2113 32
33 # VMS likes to put newlines at the end of commands if there isn't
34 # one already.
35 $expect =~ s/([^\n])\z/$1\n/ if $^O eq 'VMS';
36
37 $TB->is_eq(scalar `$cmd`, $expect, $name) || $TB->diag("oneliner:\n$cmd");
38}
39
40# Lets see how it deals with quotes.
41try_oneliner(q{print "foo'o", ' bar"ar'}, [], q{foo'o bar"ar}, 'quotes');
42
43# How about dollar signs?
44try_oneliner(q{$PATH = 'foo'; print $PATH},[], q{foo}, 'dollar signs' );
45
46# switches?
47try_oneliner(q{print 'foo'}, ['-l'], "foo\n", 'switches' );
48
49# XXX gotta rethink the newline test. The Makefile does newline
50# escaping, then the shell.
51