Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of nicholas (3034)

Sunday October 11, 2009
03:24 PM

Perl 5 is Perl 1. And TAP is 22.

[ #39741 ]

I was looking at t/op/unshift.t, and it's a bit strange:

#!./perl

print "1..2\n";

@a = (1,2,3);
$cnt1 = unshift(a,0);

if (join(' ',@a) eq '0 1 2 3') {print "ok 1\n";} else {print "not ok 1\n";}
$cnt2 = unshift(a,3,2,1);
if (join(' ',@a) eq '3 2 1 0 1 2 3') {print "ok 2\n";} else {print "not ok 2\n";}

There's no @ on the arrays passed to unshift. That's Perl 1 syntax.

Well, that's because it turns out that every line in that test is verbatim from the Perl 1.0 release test suite. Check out the "blame". I was going to tweak it to use a library for its tests, which would generate nice diagnostics on failure, but given how "1st edition" it is, I don't feel like doing that now.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • And the tests pass. But if I put my @a it fails. (If I put our @a, it passes.)

    No test of the numbers returned? :)

    • But if I put my @a it fails. (If I put our @a, it passes.)

      So, what is this, actually? Something like a glob reference? Or worse: a symbolic reference?

      It reminds me of the syntax for filehandles.

      • No, neither glob reference nor symbolic reference. A "regular" package variable. Run Deparse over it to see what the optree is:

        $ ./perl -Ilib -MO=Deparse  t/op/unshift.t
        print "1..2\n";
        @a = (1, 2, 3);
        $cnt1 = unshift(@a, 0);
        if (join(' ', @a) eq '0 1 2 3') {
            print "ok 1\n";
        }
        else {
            print "not ok 1\n";
        }
        $cnt2 = unshift(@a, 3, 2, 1);
        if (join(' ', @a) eq '3 2 1 0 1 2 3') {
            print "ok 2\n";
        }
        else {
            print "not ok 2\n";
        }
        t/op/unshift.t syntax OK

        There's similar ob