Skip to content

Commit

Permalink
Test oneliner without double escaping dollar sign
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
atoomic committed Jul 21, 2020
1 parent 570413d commit 253de6b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions t/oneliner.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ chdir 't';

use Config;
use MakeMaker::Test::Utils;
use Test::More tests => 16;
use Test::More tests => 17;
use File::Spec;

my $TB = Test::More->builder;
Expand All @@ -25,6 +25,7 @@ sub try_oneliner {
my($code, $switches, $expect, $name) = @_;
my $cmd = $mm->oneliner($code, $switches);
$cmd =~ s{\$\(ABSPERLRUN\)}{$perl};
$cmd =~ s{\$\$}{\$}g; # unescape Makefile syntax

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

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

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

0 comments on commit 253de6b

Please sign in to comment.