In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/3d7a9343ce805daaa050171aecb0ab4f37fed18d?hp=bf70f4101a9bd4064c4bc7f03a677f4227ad79a4>

- Log -----------------------------------------------------------------
commit 3d7a9343ce805daaa050171aecb0ab4f37fed18d
Author: Nicholas Clark <[email protected]>
Date:   Fri Sep 24 11:46:41 2010 +0100

    Add a warning to test.pl if quotes are used in one-liners.
    
    Fix all the tests that were using quotes, and (by implication) working
    because barewords are treated as strings, and one-liners aren't run under
    strict.
-----------------------------------------------------------------------

Summary of changes:
 ext/B/t/concise.t |    2 +-
 t/op/array.t      |    2 +-
 t/op/gv.t         |    2 +-
 t/op/ref.t        |    4 ++--
 t/run/switches.t  |   12 ++++++------
 t/test.pl         |    4 ++++
 6 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/ext/B/t/concise.t b/ext/B/t/concise.t
index 3eb22ce..2b67222 100644
--- a/ext/B/t/concise.t
+++ b/ext/B/t/concise.t
@@ -413,7 +413,7 @@ $out = runperl ( switches => 
["-MO=Concise,-stash=Data::Dumper,-src,-exec"],
 like($out, qr/FUNC: \*Data::Dumper::format_refaddr/,
      "stash rendering loads package as needed");
 
-my $prog = q{package FOO; sub bar { print "bar" } package main; FOO::bar(); };
+my $prog = q{package FOO; sub bar { print q{bar} } package main; FOO::bar(); };
 
 # this would fail if %INC used for -stash test
 $out = runperl ( switches => ["-MO=Concise,-src,-stash=FOO,-main"],
diff --git a/t/op/array.t b/t/op/array.t
index e36fd28..f100e2d 100644
--- a/t/op/array.t
+++ b/t/op/array.t
@@ -276,7 +276,7 @@ tary();
 my $got = runperl (
        prog => q{
                    sub X::DESTROY { @a = () }
-                   @a = (bless {}, 'X');
+                   @a = (bless {}, q{X});
                    @a = ();
                },
        stderr => 1
diff --git a/t/op/gv.t b/t/op/gv.t
index cc8f205..3044bd8 100644
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -286,7 +286,7 @@ $| = 1;
 sub DESTROY {eval {die qq{Farewell $_[0]}}; print $...@}
 package main;
 
-bless \$A::B, 'M';
+bless \$A::B, q{M};
 *A:: = \*B::;
 EOPROG
     like($output, qr/^Farewell M=SCALAR/, "DESTROY was called");
diff --git a/t/op/ref.t b/t/op/ref.t
index bad0168..52a4d2a 100644
--- a/t/op/ref.t
+++ b/t/op/ref.t
@@ -432,7 +432,7 @@ is ($?, 0, 'coredump on typeglob = (SvRV && !SvROK)');
 # "Attempt to free unreferenced scalar" warnings
 
 is (runperl(
-    prog => 'use Symbol;my $x=bless \gensym,"t"; print;*$$x=$x',
+    prog => 'use Symbol;my $x=bless \gensym,q{t}; print;*$$x=$x',
     stderr => 1
 ), '', 'freeing self-referential typeglob');
 
@@ -443,7 +443,7 @@ is (runperl(
 TODO: {
     local $TODO = "works but output through pipe is mangled" if $^O eq 'VMS';
     like (runperl(
-        prog => '$x=bless[]; sub 
IO::Handle::DESTROY{$_="bad";s/bad/ok/;print}',
+        prog => '$x=bless[]; sub 
IO::Handle::DESTROY{$_=q{bad};s/bad/ok/;print}',
         stderr => 1
           ), qr/^(ok)+$/, 'STDOUT destructor');
 }
diff --git a/t/run/switches.t b/t/run/switches.t
index 20cb772..ada6eaf 100644
--- a/t/run/switches.t
+++ b/t/run/switches.t
@@ -200,27 +200,27 @@ SWTESTPM
          '', "-MFoo::Bar allowed" );
 
     like( runperl( switches => [ "-M:$package" ], stderr => 1,
-                  prog => 'die "oops"' ),
+                  prog => 'die q{oops}' ),
          qr/Invalid module name [\w:]+ with -M option\b/,
           "-M:Foo not allowed" );
 
     like( runperl( switches => [ '-mA:B:C' ], stderr => 1,
-                  prog => 'die "oops"' ),
+                  prog => 'die q{oops}' ),
          qr/Invalid module name [\w:]+ with -m option\b/,
           "-mFoo:Bar not allowed" );
 
     like( runperl( switches => [ '-m-A:B:C' ], stderr => 1,
-                  prog => 'die "oops"' ),
+                  prog => 'die q{oops}' ),
          qr/Invalid module name [\w:]+ with -m option\b/,
           "-m-Foo:Bar not allowed" );
 
     like( runperl( switches => [ '-m-' ], stderr => 1,
-                  prog => 'die "oops"' ),
+                  prog => 'die q{oops}' ),
          qr/Module name required with -m option\b/,
          "-m- not allowed" );
 
     like( runperl( switches => [ '-M-=' ], stderr => 1,
-                  prog => 'die "oops"' ),
+                  prog => 'die q{oops}' ),
          qr/Module name required with -M option\b/,
          "-M- not allowed" );
   }  # disable TODO on VMS
@@ -293,7 +293,7 @@ foreach my $switch (split //, 
"ABbGgHJjKkLNOoPQqRrYyZz123456789_")
     local $TODO = '';   # these ones should work on VMS
 
     like( runperl( switches => ["-$switch"], stderr => 1,
-                  prog => 'die "oops"' ),
+                  prog => 'die q{oops}' ),
          qr/\QUnrecognized switch: -$switch  (-h will show valid options)./,
           "-$switch correctly unknown" );
 
diff --git a/t/test.pl b/t/test.pl
index f26627d..a136a4f 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -427,6 +427,7 @@ USE_OK
 # Arguments :
 #   switches => [ command-line switches ]
 #   nolib    => 1 # don't use -I../lib (included by default)
+#   non_portable => Don't warn if a one liner contains quotes
 #   prog     => one-liner (avoid quotes)
 #   progs    => [ multi-liner (avoid quotes) ]
 #   progfile => perl script
@@ -480,6 +481,9 @@ sub _create_runperl { # Create the string to qx in 
runperl().
        die "test.pl:runperl(): 'progs' must be an ARRAYREF " . _where()
            unless ref $args{progs} eq "ARRAY";
         foreach my $prog (@{$args{progs}}) {
+           if ($prog =~ tr/'"// && !$args{non_portable}) {
+               warn "quotes in prog >>$prog<< are not portable";
+           }
             if ($is_mswin || $is_netware || $is_vms) {
                 $runperl = $runperl . qq ( -e "$prog" );
             }

--
Perl5 Master Repository

Reply via email to