File Coverage

lib/Test/Chai/Interface/Expect.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 2 100.0
condition n/a
subroutine 10 10 100.0
pod 0 4 0.0
total 38 42 90.4


line stmt bran cond sub pod time code
1             package Test::Chai::Interface::Expect;
2 2     2   1915 use strict;
  2         4  
  2         55  
3 2     2   10 use warnings;
  2         3  
  2         52  
4 2     2   11 use utf8;
  2         4  
  2         10  
5              
6 2     2   52 use Exporter qw/import/;
  2         2  
  2         113  
7             our @EXPORT = qw/expect/;
8              
9 2     2   12 use Test::Chai::Assertion;
  2         5  
  2         17  
10 2     2   352 use Test::Chai::AssertionError;
  2         160  
  2         459  
11 321     321 0 1383 sub Assertion { 'Test::Chai::Assertion' }
12 1     1 0 14 sub AssertionError { 'Test::Chai::AssertionError' }
13              
14             my $CLASS = __PACKAGE__;
15              
16             sub expect {
17 321     321 0 85640 my ($val, $message) = @_;
18 321 100       947 return bless {} => $CLASS if @_ == 0;
19 320         757 return Assertion->new($val, $message);
20             }
21              
22             # expect->fail(actual, expected, [message], [operator])
23             sub fail {
24 1     1 0 3 my ($self, $actual, $expected, $message, $operator) = @_;
25              
26 1         6 my $err = AssertionError->new($message, {
27             actual => $actual,
28             expected => $expected,
29             operator => $operator,
30             }, $CLASS.'::fail');
31 1         5 return Assertion->new->_fail($err->message);
32             }
33              
34             1;