File: 35_Class_Throwable_sub_class_test.t

package info (click to toggle)
libclass-throwable-perl 0.10-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, lenny, squeeze, wheezy
  • size: 108 kB
  • ctags: 20
  • sloc: perl: 447; makefile: 43
file content (36 lines) | stat: -rw-r--r-- 753 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
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 4;

use lib qw(t/);

BEGIN {
    use_ok('TestException' => (VERBOSE => 2));
}

my $path_seperator = "/";
$path_seperator = "\\" if $^O eq 'MSWin32';
$path_seperator = ":"  if $^O eq 'MacOS';

eval {
	throw TestException "This is my message";
};

my $expected = <<EXPECTED;
TestException : This is my message
  |--[ main::(eval) called in t${path_seperator}35_Class_Throwable_sub_class_test.t line 18 ]
EXPECTED

is($@, $expected, '... got the output we expected');

can_ok("TestException", 'setVerbosity');

TestException->setVerbosity(1);

eval {
	throw TestException "This is my other message";
};
is($@, 'TestException : This is my other message', '... got the output we expected');