82dee7de92a0bd35 failed to add ext/lib/Makefile.PL. Oops.
[p5sagit/p5-mst-13.2.git] / ext / ExtUtils-MakeMaker / t / oneliner.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     unshift @INC, 't/lib';
5 }
6
7 chdir 't';
8
9 use MakeMaker::Test::Utils;
10 use Test::More tests => 6;
11 use File::Spec;
12
13 my $TB = Test::More->builder;
14
15 BEGIN { use_ok('ExtUtils::MM') }
16
17 my $mm = bless { NAME => "Foo" }, 'MM';
18 isa_ok($mm, 'ExtUtils::MakeMaker');
19 isa_ok($mm, 'ExtUtils::MM_Any');
20
21
22 sub try_oneliner {
23     my($code, $switches, $expect, $name) = @_;
24     my $cmd = $mm->oneliner($code, $switches);
25     $cmd =~ s{\$\(ABSPERLRUN\)}{$^X};
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.
35 try_oneliner(q{print "foo'o", ' bar"ar'}, [],  q{foo'o bar"ar},  'quotes');
36
37 # How about dollar signs?
38 try_oneliner(q{$PATH = 'foo'; print $PATH},[], q{foo},   'dollar signs' );
39
40 # switches?
41 try_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