File: preserve.t

package info (click to toggle)
libtest-exception-perl 0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 176 kB
  • sloc: perl: 400; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 488 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /usr/bin/perl -Tw

use strict;
use warnings;

use Test::More tests => 5;

BEGIN { use_ok( 'Test::Exception' ) };

sub div {
   my ($a, $b) = @_;
   return( $a / $b );
};

dies_ok { div(1, 0) } 'exception thrown okay in dies_ok';
like( $@, '/^Illegal division by zero/', 'exception preserved after dies_ok' );

throws_ok { div(1, 0) } '/^Illegal division by zero/', 'exception thrown okay in throws_ok';
like( $@, '/^Illegal division by zero/', 'exception preserved after thrown_ok' );