blib/lib/Text/Nunjucks/Lib/Error.pm

filter: Statementstmt 100% 16 / 16 Branchbran 50.0% 1 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 85.1% 23 / 27 CC 3 SCAR 7.2
CC
3
Cov
90%
__ANON__
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« blib/lib/Text/Nunjucks/Loader.pm ↑ Summary blib/lib/Text/Nunjucks/Nodes/FromImport.pm »
1 package Text::Nunjucks::Lib::Error;
2 # ABSTRACT: Port representation of a JS built-in Error / TypeError (name + message)
3  
4 23 our $VERSION = '0.001';
5  
6 23 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 23 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # src/lib.js reaches for the JS globals `new Error(...)` (inOperator) and
10 # `new TypeError(...)` (groupBy). Perl has no universal Error base, so the port
11 # models a thrown JS error as a small object carrying { name, message } -- the
12 # two fields _prettifyError reads back ("${cause.name}: ${cause.message}") and
13 # the corpus harness reads (->name / ->message). `name` defaults to 'Error';
14 # callers that want a different JS error type pass name => 'TypeError'.
15 #
16 # NOTE (open mapping): how JS built-in error types map to Perl is not yet
17 # settled by an ADR -- see the k9 report. This class is the single, minimal
18 # place that representation is encapsulated.
19  
20 23 has message => ( is => 'ro' );
21 281 ▶has name => ( is => 'ro', default => sub { 'Error' } );
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 1587 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=3 SCAR=11.3
24 1587 my ( $orig, $class, @args ) = @_;
25 1587 ▶ return $class->$orig(@args) if @args == 1 && ref $args[0] eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if @args == 1 and ref $args[0] eq "HASH" 0 1587 1587
Condition66%2/3
@args == 1 and ref $args[0] eq "HASH"
!ll&&!rl&&r
13062810
MC/DC0%0/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1 ref $args[0] eq "HASH"
Truth table66%2/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
ABresult
0X0
100
111
26 1587 my ( $message, %opts ) = @args;
27 1587 return $class->$orig( message => $message, %opts );
28 23 };
29  
30 23 1;
31  
32 __END__
« blib/lib/Text/Nunjucks/Loader.pm ↑ Summary blib/lib/Text/Nunjucks/Nodes/FromImport.pm »