xref: /openbsd-src/gnu/usr.bin/perl/cpan/ExtUtils-MakeMaker/t/oneliner.t (revision d13be5d47e4149db2549a9828e244d59dbc43f15)
1#!/usr/bin/perl -w
2
3BEGIN {
4    unshift @INC, 't/lib';
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);
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.
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
46