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