File Coverage

blib/lib/Perl6/Builtins.pm
Criterion Covered Total %
statement 36 36 100.0
branch 5 6 83.3
condition 4 6 66.6
subroutine 13 13 100.0
pod n/a
total 58 61 95.0


line stmt bran cond sub pod time code
1             package Perl6::Builtins;
2              
3 3     3   66094 use version; $VERSION = qv('0.0.3');
  3         8904  
  3         21  
4              
5 3     3   703 use warnings;
  3         12  
  3         95  
6 3     3   15 use strict;
  3         10  
  3         78  
7 3     3   13 use Carp;
  3         5  
  3         425  
8              
9             sub import {
10 3     3   8500 use Contextual::Return;
  3         74917  
  3         27  
11 3     3   28 my $package = shift;
12              
13             # system...
14 3 50 66     34 if (!@_ || grep m/\A system \z/xms, @_) {
15 3         10 *CORE::GLOBAL::system = \&_p6_system;
16             }
17              
18             # caller...
19 3 100 66     65 if (!@_ || grep m/\A caller \z/xms, @_) {
20 2         2388 *CORE::GLOBAL::caller = \&_p6_caller;
21             }
22             }
23              
24             sub _p6_system {
25 4     4   5096 undef $!;
26 4         32883 my $status = CORE::system @_;
27 4         283 my $error = $!;
28             return
29 4     4   4584 BOOL { !$status }
30 4     2   456 VALUE { $error };
  2         4237  
31             }
32              
33             my @CALLER_FIELDS = qw(
34             package
35             file
36             line
37             sub
38             args
39             want
40             eval
41             require
42             hints
43             bitmask
44             );
45              
46             sub _p6_caller {
47 14     14   56443 my @caller;
48 14 100       56 if (@_) {
49 9         65 @caller = CORE::caller($_[0]+1);
50             }
51             else {
52 5         44 @caller = (CORE::caller(1))[0..2];
53             }
54             return (
55 9     9   2475 HASHREF { my %hash;
56 9         72 @hash{@CALLER_FIELDS} = @caller;
57 9         32 \%hash;
58             }
59 1     1   527 SCALAR { $caller[0]; }
60 4     4   1227 LIST { @caller; }
61 14         196 );
62             }
63              
64             1; # Magic true value required at end of module
65             __END__