Skip to content

Commit db19381

Browse files
committed
Test oneliner without double escaping dollar sign
Fix Perl-Toolchain-Gang#355 Double escaping '$' for Makefile usage is fine, but we should not use such a syntax while testing and trying to run the oneliner output. This change is 'unescaping' the '$$' to '$' so we can perform some extra checks while using oneliner. Otherwise as shown in this example a simple 'my $foo' test will fail.
1 parent 570413d commit db19381

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

t/oneliner.t

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ chdir 't';
88

99
use Config;
1010
use MakeMaker::Test::Utils;
11-
use Test::More tests => 16;
11+
use Test::More tests => 17;
1212
use File::Spec;
1313

1414
my $TB = Test::More->builder;
@@ -24,6 +24,7 @@ isa_ok($mm, 'ExtUtils::MM_Any');
2424
sub try_oneliner {
2525
my($code, $switches, $expect, $name) = @_;
2626
my $cmd = $mm->oneliner($code, $switches);
27+
$cmd =~ s{\$\$}{\$}g; # unescape Makefile syntax
2728
$cmd =~ s{\$\(ABSPERLRUN\)}{$perl};
2829

2930
# VMS likes to put newlines at the end of commands if there isn't
@@ -37,7 +38,8 @@ sub try_oneliner {
3738
try_oneliner(q{print "foo'o", ' bar"ar'}, [], q{foo'o bar"ar}, 'quotes');
3839

3940
# How about dollar signs?
40-
try_oneliner(q{$PATH = 'foo'; print $PATH},[], q{foo}, 'dollar signs' );
41+
try_oneliner(q{my $PATH = 'foo'; print $PATH},[], q{foo}, 'dollar signs' );
42+
try_oneliner(q{my %h = (1, 2); print $h{1}},[], q{2}, '%h and $h' );
4143

4244
# switches?
4345
try_oneliner(q{print 'foo'}, ['-l'], "foo\n", 'switches' );

0 commit comments

Comments
 (0)