File: | quux.t |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!/usr/bin/perl | ||||||
2 | |||||||
3 | #=============================================================================== | ||||||
4 | # REVISION: $Id:$ | ||||||
5 | # DESCRIPTION: Test for Quux module | ||||||
6 | #=============================================================================== | ||||||
7 | |||||||
8 | 1 1 1 | 13 1 4 | use strict; | ||||
9 | 1 1 1 | 4 1 4 | use warnings; | ||||
10 | |||||||
11 | 1 | 3 | our $VERSION = qw($Revision$) [1]; | ||||
12 | |||||||
13 | 1 1 1 | 9 1 7 | use Readonly; | ||||
14 | 1 1 1 | 7 1 4 | use English qw( -no_match_vars ); | ||||
15 | |||||||
16 | 1 1 1 | 7 2 5 | use FindBin qw($Bin); | ||||
17 | 1 1 1 | 6 2 9 | use lib "$Bin"; | ||||
18 | |||||||
19 | 1 1 1 | 6 1 7 | use Quux; | ||||
20 | |||||||
21 | 1 1 1 | 6 1 6 | use Test::More tests => 3; | ||||
22 | 1 1 1 | 8 1 3 | use Test::Exception; | ||||
23 | |||||||
24 | 1 | 4 | Readonly my $TEST_FILE => '/dev/null'; | ||||
25 | 1 | 3 | Readonly my $NO_SUCH_FILE => '/no/such/file'; | ||||
26 | |||||||
27 | sub run_tests { | ||||||
28 | 1 | 5 | my $quux = Quux->new(); | ||||
29 | |||||||
30 | 1 | 1 | my $result; | ||||
31 | |||||||
32 | 1 | 4 | $result = $quux->foo( $TEST_FILE, 1, 1 ); | ||||
33 | 1 | 7 | ok( $result, 'Check var1=1 and var2=1' ); | ||||
34 | |||||||
35 | 1 | 4 | $result = $quux->foo( $TEST_FILE, 0, 0, 'some_flag' ); | ||||
36 | 1 | 5 | ok( $result, 'Check var1=0 and var2=0' ); | ||||
37 | |||||||
38 | # We haven't checked var1=1,var2=0 and var1=0,var2=1 but | ||||||
39 | # branch-coverage for method foo() will be 100% | ||||||
40 | |||||||
41 | 1 | 60 | dies_ok { $quux->foo( $NO_SUCH_FILE, 'no_matter', 'no_matter' ) } | ||||
42 | 1 | 3 | "Try to open non-existent file '$NO_SUCH_FILE'"; | ||||
43 | |||||||
44 | 1 | 7 | return; | ||||
45 | } | ||||||
46 | |||||||
47 | 1 | 2 | run_tests(); |