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 ]

Monday March 06, 2006
01:57 PM

Who'da thunk

[ #28895 ]

... that this would work?

SKIP: {
   print "first\n";
   SKIP: {
     print "second\n";
     SKIP: {
     print "third\n";
     last SKIP;
     print "shouldn't print\n";
     }
     print "leaving second\n";
   }
   print "leaving first\n";
}

with output

first
second
third
leaving second
leaving first

Not only does it compile, but it works as you'd expect: the last leaves only the innermost SKIP block. Or maybe I should say "it works the way I want it to".

This means that Test::More SKIP blocks can be nested and the Right Thing will happen. Why this matters will be made clear in a module I'll be releasing soon that wraps up Test::More-like retryable tests in a nice syntax.

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.
  • That's one of the points we drive home in there. last/next/redo work with the innermost enclosing loop-ish block (naked block counts) that matches the name, or if the name isn't given, the innermost block.
    --
    • Randal L. Schwartz
    • Stonehenge
    • Actually, I haven't. I went straight from Pink Camel to Blue Camel via man page, so I've probably missed a few interesting items here and there...

      Looking back, it's not so surprising - I knew that last was pretty intelligent in its behavior, and that it was perfectly OK to have the same label in a program multiple times (e.g - multiple SKIP blocks in a test). I just hadn't explicitly nested multiple identical labels before, and was quite pleased that it worked, since I need it to.