File Coverage

blib/lib/Syntax/Keyword/Assert.pm
Criterion Covered Total %
statement 25 26 96.1
branch 3 6 50.0
condition n/a
subroutine 10 10 100.0
pod 0 3 0.0
total 38 45 84.4


line stmt bran cond sub pod time code
1             package Syntax::Keyword::Assert 0.19;
2              
3 11     11   2548442 use v5.14;
  11         45  
4 11     11   64 use warnings;
  11         28  
  11         622  
5              
6 11     11   92 use Carp ();
  11         20  
  11         4205  
7              
8             require XSLoader;
9             XSLoader::load( __PACKAGE__, our $VERSION );
10              
11             sub import {
12 10     10   88 my $pkg = shift;
13 10         25 my $caller = caller;
14              
15 10         35 $pkg->import_into( $caller, @_ );
16             }
17              
18             sub unimport {
19 1     1   12 my $pkg = shift;
20 1         3 my $caller = caller;
21              
22 1         4 $pkg->unimport_into( $caller, @_ );
23             }
24              
25 10     10 0 98 sub import_into { shift->apply( sub { $^H{ $_[0] }++ }, @_ ) }
  10     10   57  
26 1     1 0 5 sub unimport_into { shift->apply( sub { delete $^H{ $_[0] } }, @_ ) }
  1     1   6  
27              
28             sub apply {
29 11     11 0 22 my $pkg = shift;
30 11         33 my ( $cb, $caller, @syms ) = @_;
31              
32 11 50       54 @syms or @syms = qw( assert );
33              
34 11         35 my %syms = map { $_ => 1 } @syms;
  11         57  
35 11 50       67 $cb->( "Syntax::Keyword::Assert/assert" ) if delete $syms{assert};
36              
37 11 50       8887 Carp::croak "Unrecognised import symbols @{[ keys %syms ]}" if keys %syms;
  0            
38             }
39              
40             1;
41             __END__