-
Notifications
You must be signed in to change notification settings - Fork 38
/
messages.t
55 lines (37 loc) · 972 Bytes
/
messages.t
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
53
54
#!/usr/bin/perl -w
use Test::More;
use strict;
# test catching of error and warnings:
BEGIN
{
plan tests => 10;
chdir 't' if -d 't';
use lib '../lib';
use_ok ("Graph::Easy") or die($@);
};
can_ok ("Graph::Easy", qw/
catch_messages
catch_errors
catch_warnings
errors
warnings
/);
#############################################################################
# adding edges/nodes
my $graph = Graph::Easy->new();
is (ref($graph), 'Graph::Easy');
is ($graph->error(), '', 'no error yet');
$graph->catch_messages(1);
$graph->error('foo');
my @errors = $graph->errors();
my @warnings = $graph->warnings();
is (scalar @errors, 1, '1 error');
is (scalar @warnings, 0, '0 warnings');
is ($errors[0], 'foo', '1 error');
$graph->warn('Bar');
@errors = $graph->errors();
@warnings = $graph->warnings();
is (scalar @errors, 1, '1 error');
is (scalar @warnings, 1, '1 warning');
is ($warnings[0], 'Bar', '1 warning');
1; # all tests done