'or BAIL_OUT' idiom
ok(), is(), and other functions exported by Test::More returns 1 if succeeded, 0 otherwise.
So you know the idiom using this return value
ok($foo) or diag Dumper($stuff);
And today, i introduce a "subtest $name => sub { ... } or BAIL_OUT" idiom.
Sometime, you may want to stop the test script after failing, so I recommend this idiom.
subtest "my failing test" => sub {
ok $thing;
} or BAIL_OUT;
Then, test script bail outs if subtest was failed.
【Note】
You can use "or die" :P
Published: 2011-11-14(Mon) 05:01