| 1 | # -*- mode: perl; coding: utf-8 -*- | ||||||||||||||||||||||||||||
| 2 | package YATT::Util::Enum; | ||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings qw(FATAL all NONFATAL misc); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use YATT::Util::Symbol qw/define_const/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 26 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=12 SCAR=26.9
| |||||||||||||||||||||||||||||
| 9 | 26 | my ($pack) = shift; | |||||||||||||||||||||||||||
| 10 | 26 | my $callpack = caller; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | #---------------------------------------- | ||||||||||||||||||||||||||||
| 13 | 26 | my %opts; | |||||||||||||||||||||||||||
| 14 | 26 | ▶ | for (; @_ and $_[0] =~ /^-(\w+)/; splice @_, 0, 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ and $_[0] =~ /^-(\w+)/
MC/DC50%1/2
@_ and $_[0] =~ /^-(\w+)/
@_
$_[0] =~ /^-(\w+)/
Truth table66%2/3
A and B
A= @_B= $_[0] =~ /^-(\w+)/
| |||||||||||||||||||||||||||||
| 15 | 19 | $opts{$1} = $_[1]; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | 26 | ▶ | my $offset = delete $opts{offset} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
delete $opts{'offset'} || 0
MC/DC0%0/1
delete $opts{'offset'} || 0
delete $opts{'offset'}
Truth table50%1/2
A
A= delete $opts{'offset'}
| |||||||||||||||||||||||||||||
| 18 | 26 | ▶ | my $prefix = delete $opts{prefix} || ""; | ||||||||||||||||||||||||||
|
Condition100%2/2
delete $opts{'prefix'} || ''
MC/DC100%1/1
delete $opts{'prefix'} || ''
delete $opts{'prefix'}
Truth table100%2/2
A
A= delete $opts{'prefix'}
| |||||||||||||||||||||||||||||
| 19 | my $export = delete $opts{export} | ||||||||||||||||||||||||||||
| 20 | 26 | ▶ | ? $callpack . "::EXPORT" : ""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | my $export_ok = $export || delete $opts{export_ok} | ||||||||||||||||||||||||||||
| 22 | 26 | ▶ | ? $callpack . "::EXPORT_OK" : ""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$export or delete $opts{"export_ok"}
MC/DC0%0/2
$export or delete $opts{"export_ok"}
$export
delete $opts{"export_ok"}
Truth table33%1/3
A or B
A= $exportB= delete $opts{"export_ok"}
| |||||||||||||||||||||||||||||
| 23 | 26 | ▶ | die "Unknown options for " . __PACKAGE__ . "\n". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | join ", ", keys %opts if keys %opts; | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | #---------------------------------------- | ||||||||||||||||||||||||||||
| 27 | 26 | foreach my $item (@_) { | |||||||||||||||||||||||||||
| 28 | 155 | my $full_name = $callpack . "::" . $prefix . $item; | |||||||||||||||||||||||||||
| 29 | { | ||||||||||||||||||||||||||||
| 30 | 155 | define_const($full_name, $offset); | |||||||||||||||||||||||||||
| 31 | 0 | ▶ | push @{$export}, $full_name if $export; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | push @{$export_ok}, $full_name if $export_ok; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | } continue { | ||||||||||||||||||||||||||||
| 35 | 155 | $offset++; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 8 | 1; | |||||||||||||||||||||||||||