File: return.t

package info (click to toggle)
libtest-exception-perl 0.20-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 144 kB
  • ctags: 194
  • sloc: makefile: 459; perl: 328
file content (52 lines) | stat: -rw-r--r-- 1,031 bytes parent folder | download | duplicates (2)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/perl -Tw

use strict;
use Test::Builder;
use Test::Harness;
use Test::More tests => 13;

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

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

my $ok;

$ok = 0;
$ok = dies_ok { div(1, 0) } 'dies_ok succeeded';
ok($ok, 'dies_ok returned true on success');

TODO: {
	$ok = 1;
	local $TODO = "testing dies_ok failure";
	$ok = dies_ok { div(1, 1) } 'dies_ok failed';
};
ok(!$ok, 'dies_ok returned false on failure');


$ok = 0;
$ok = throws_ok { div(1, 0) } '/./', 'throws_ok succeeded';
ok($ok, 'throws_ok returned true on success');

TODO: {
	$ok = 1;
	local $TODO = "testing throws_ok failure";
	$ok = throws_ok { div(1, 1) } '/./', 'throws_ok failed';
};
ok(!$ok, 'throws_ok returned false on failure');


$ok = 0;
$ok = lives_ok { div(1, 1) } 'lives_ok succeeded';
ok($ok, 'lives_ok returned true on success');

TODO: {
	$ok = 1;
	local $TODO = "testing lives_ok failure";
	$ok = lives_ok { div(1, 0) } 'lives_ok failed';
};
ok(!$ok, 'lives_ok returned false on failure');