File: RECOVER_exception.t

package info (click to toggle)
libcontextual-return-perl 0.003001-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 324 kB
  • ctags: 52
  • sloc: perl: 1,187; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 582 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use Contextual::Return;
use Test::More tests => 8;

no warnings 'uninitialized';

sub foo {
    return
        BOOL      { die 'oops! Bool'; 1              }
        NUM       { die 'oops! Num'; return 7;       }
        STR       { die 'oops! Num'; return 7;       }
        VOID      { die 'Enter not the Abyss!';      }
        RECOVER   { ok 1 => "Recovered";             } 
    ;
}

my $foo = foo();

ok +($foo?0:1)                  => 'BOOLEAN';
ok not("$foo")                  => 'STRING';
ok not(0+$foo)                  => 'NUM';
ok do{;foo;1}                   => 'VOID';