File: 09dollar-at.t

package info (click to toggle)
liberror-perl 0.17-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze, wheezy
  • size: 196 kB
  • ctags: 63
  • sloc: perl: 1,056; makefile: 38
file content (36 lines) | stat: -rw-r--r-- 1,045 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl

use strict;
use warnings;

use Error qw(:try);
use Test::More tests => 8;

my $dollar_at;
my $arg_0;

try {
    throw Error::Simple( "message" );
}
catch Error::Simple with {
    $arg_0 = shift;
    $dollar_at = $@;
};

ok( defined $arg_0,     'defined( $_[0] ) after throw/catch' );
ok( defined $dollar_at, 'defined( $@ ) after throw/catch' );
ok( ref $arg_0     && $arg_0->isa( "Error::Simple" ),     '$_[0]->isa( "Error::Simple" ) after throw/catch' );
ok( ref $dollar_at && $dollar_at->isa( "Error::Simple" ), '$@->isa( "Error::Simple" ) after throw/catch' );

try {
    throw Error::Simple( "message" );
}
otherwise {
    $arg_0 = shift;
    $dollar_at = $@;
};

ok( defined $arg_0,     'defined( $_[0] ) after throw/otherwise' );
ok( defined $dollar_at, 'defined( $@ ) after throw/otherwise' );
ok( ref $arg_0     && $arg_0->isa( "Error::Simple" ),     '$_[0]->isa( "Error::Simple" ) after throw/otherwise' );
ok( ref $dollar_at && $dollar_at->isa( "Error::Simple" ), '$@->isa( "Error::Simple" ) after throw/otherwise' );