Who'da thunk

pemungkah on 2006-03-06T18:57:23

... 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.


Never read the llama, I take it?

merlyn on 2006-03-07T15:47:33

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.

Re:Never read the llama, I take it?

pemungkah on 2006-03-07T19:09:50

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.