| 1 | package Test::Data::Sah::Human; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use 5.010001; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use Test::More 0.98; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | use Data::Sah; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 3 | ▶ | use Exporter qw(import); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 3 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||
| 13 | 3 | our $DATE = '2024-02-16'; # DATE | |||||||||||||||||||
| 14 | 3 | our $DIST = 'Data-Sah'; # DIST | |||||||||||||||||||
| 15 | 3 | our $VERSION = '0.917'; # VERSION | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 3 | our @EXPORT_OK = qw(test_human); | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 16 | ▶ | sub test_human { | ||||||||||||||||||
|
Subroutine
test_human: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||
| 20 | 16 | my %args = @_; | |||||||||||||||||||
| 21 | 16 | ▶ | subtest $args{name} // $args{result}, sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.3
| |||||||||||||||||||||
| 22 | 16 | my $sah = Data::Sah->new; | |||||||||||||||||||
| 23 | 16 | my $hc = $sah->get_compiler("human"); | |||||||||||||||||||
| 24 | my %hargs = ( | ||||||||||||||||||||
| 25 | schema => $args{schema}, | ||||||||||||||||||||
| 26 | lang => $args{lang}, | ||||||||||||||||||||
| 27 | 16 | ▶ | %{ $args{compile_opts} // {} }, | ||||||||||||||||||
|
Condition50%1/2
$args{"compile_opts"} // {}
MC/DC0%0/1
$args{"compile_opts"} // {}
$args{"compile_opts"}
Truth table50%1/2
A
A= $args{"compile_opts"}
| |||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||
| 29 | 16 | ▶ | $hargs{format} //= "inline_text"; | ||||||||||||||||||
|
Condition50%1/2
$hargs{"format"} //= "inline_text"
MC/DC0%0/1
$hargs{"format"} //= "inline_text"
$hargs{"format"}
Truth table50%1/2
A
A= $hargs{"format"}
| |||||||||||||||||||||
| 30 | 16 | my $cd = $hc->compile(%hargs); | |||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 16 | ▶ | if (defined $args{result}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | 16 | ▶ | if (ref($args{result}) eq 'Regexp') { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | 2 | like($cd->{result}, $args{result}, 'result'); | |||||||||||||||||||
| 35 | } else { | ||||||||||||||||||||
| 36 | 14 | is($cd->{result}, $args{result}, 'result'); | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | 16 | ▶ | }; | ||||||||||||||||||
|
Condition33%1/3
$args{"name"} // $args{"result"}
MC/DC0%0/2
$args{"name"} // $args{"result"}
$args{"name"}
$args{"result"}
Truth table33%1/3
A // B
A= $args{"name"}B= $args{"result"}
| |||||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 3 | 1; | |||||||||||||||||||
| 43 | # ABSTRACT: Routines to test Data::Sah (human compiler) | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||