| 1 | package TestML1::Compiler::Lite; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use TestML1::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | extends 'TestML1::Compiler'; | |||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use TestML1::Runtime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 5 | has input => (); | |||||||||||||||||||||||||||
| 9 | 5 | has points => (); | |||||||||||||||||||||||||||
| 10 | 5 | has tokens => (); | |||||||||||||||||||||||||||
| 11 | 5 | has function => (); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 5 | my $WS = qr!\s+!; | |||||||||||||||||||||||||||
| 14 | 5 | my $ANY = qr!.!; | |||||||||||||||||||||||||||
| 15 | 5 | my $STAR = qr!\*!; | |||||||||||||||||||||||||||
| 16 | 5 | my $NUM = qr!-?[0-9]+!; | |||||||||||||||||||||||||||
| 17 | 5 | my $WORD = qr![-\w]+!; | |||||||||||||||||||||||||||
| 18 | 5 | my $HASH = qr!#!; | |||||||||||||||||||||||||||
| 19 | 5 | my $EQ = qr!=!; | |||||||||||||||||||||||||||
| 20 | 5 | my $TILDE = qr!~!; | |||||||||||||||||||||||||||
| 21 | 5 | my $LP = qr!\(!; | |||||||||||||||||||||||||||
| 22 | 5 | my $RP = qr!\)!; | |||||||||||||||||||||||||||
| 23 | 5 | my $DOT = qr!\.!; | |||||||||||||||||||||||||||
| 24 | 5 | my $COMMA = qr!,!; | |||||||||||||||||||||||||||
| 25 | 5 | my $SEMI = qr!;!; | |||||||||||||||||||||||||||
| 26 | 5 | my $SSTR = qr!'(?:[^']*)'!; | |||||||||||||||||||||||||||
| 27 | 5 | my $DSTR = qr!"(?:[^"]*)"!; | |||||||||||||||||||||||||||
| 28 | 5 | my $ENDING = qr!(?:$RP|$COMMA|$SEMI)!; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 5 | my $POINT = qr!$STAR$WORD!; | |||||||||||||||||||||||||||
| 31 | 5 | my $QSTR = qr!(?:$SSTR|$DSTR)!; | |||||||||||||||||||||||||||
| 32 | 5 | my $COMP = qr!(?:$EQ$EQ|$TILDE$TILDE)!; | |||||||||||||||||||||||||||
| 33 | 5 | my $OPER = qr!(?:$COMP|$EQ)!; | |||||||||||||||||||||||||||
| 34 | 5 | my $PUNCT = qr!(?:$LP|$RP|$DOT|$COMMA|$SEMI)!; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 5 | my $TOKENS = qr!(?:$POINT|$NUM|$WORD|$QSTR|$PUNCT|$OPER)!; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 5 | our $block_marker = '==='; | |||||||||||||||||||||||||||
| 39 | 5 | our $point_marker = '---'; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 4 | ▶ | sub compile_code { | ||||||||||||||||||||||||||
|
Subroutine
compile_code: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||
| 43 | 4 | $self->{function} = TestML1::Function->new; | |||||||||||||||||||||||||||
| 44 | 4 | ▶ | while (length $self->{code}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 48 | $self->{code} =~ s{^(.*)(\r\n|\n|)}{}; | |||||||||||||||||||||||||||
| 46 | 48 | $self->{line} = $1; | |||||||||||||||||||||||||||
| 47 | 48 | $self->tokenize; | |||||||||||||||||||||||||||
| 48 | 48 | ▶ | next if $self->done; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 17 | ▶ | $self->parse_assignment || | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->parse_assignment or $self->parse_assertion
MC/DC0%0/2
$self->parse_assignment or $self->parse_assertion
$self->parse_assignment
$self->parse_assertion
Truth table66%2/3
A or B
A= $self->parse_assignmentB= $self->parse_assertion
| |||||||||||||||||||||||||||||
| 50 | $self->parse_assertion || | ||||||||||||||||||||||||||||
| 51 | $self->fail; | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 48 | ▶ | sub tokenize { | ||||||||||||||||||||||||||
|
Subroutine
tokenize: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 48 | my ($self) = @_; | |||||||||||||||||||||||||||
| 57 | 48 | $self->{tokens} = []; | |||||||||||||||||||||||||||
| 58 | 48 | ▶ | while (length $self->{line}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 132 | ▶ | next if $self->{line} =~ s/^$WS//; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 96 | ▶ | next if $self->{line} =~ s/^$HASH$ANY*//; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 96 | ▶ | if ($self->{line} =~ s/^($TOKENS)//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 96 | push @{$self->{tokens}}, $1; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||
| 65 | 0 | $self->fail("Failed to get token here: '$self->{line}'"); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 17 | ▶ | sub parse_assignment { | ||||||||||||||||||||||||||
|
Subroutine
parse_assignment: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 71 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||
| 72 | 17 | ▶ | return unless $self->peek(2) eq '='; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 6 | my ($var, $op) = $self->pop(2); | |||||||||||||||||||||||||||
| 74 | 6 | my $expr = $self->parse_expression; | |||||||||||||||||||||||||||
| 75 | 6 | ▶ | $self->pop if not $self->done and $self->peek eq ';'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->done and $self->peek eq ";"
MC/DC50%1/2
not $self->done and $self->peek eq ";"
not $self->done
$self->peek eq ";"
Truth table66%2/3
not(A) and B
A= not $self->doneB= $self->peek eq ";"
| |||||||||||||||||||||||||||||
| 76 | 6 | ▶ | $self->fail unless $self->done; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 6 | push @{$self->function->statements}, | |||||||||||||||||||||||||||
| 78 | TestML1::Assignment->new(name => $var, expr => $expr); | ||||||||||||||||||||||||||||
| 79 | 6 | return 1; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 11 | ▶ | sub parse_assertion { | ||||||||||||||||||||||||||
|
Subroutine
parse_assertion: called CC=8 SCAR=21.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 11 | my ($self) = @_; | |||||||||||||||||||||||||||
| 84 | 11 | ▶ | return unless grep /^$COMP$/, @{$self->tokens}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 11 | $self->{points} = []; | |||||||||||||||||||||||||||
| 86 | 11 | my $left = $self->parse_expression; | |||||||||||||||||||||||||||
| 87 | 11 | my $token = $self->pop; | |||||||||||||||||||||||||||
| 88 | 11 | ▶ | my $op = | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 89 | $token eq '==' ? 'EQ' : | ||||||||||||||||||||||||||||
| 90 | $token eq '~~' ? 'HAS' : | ||||||||||||||||||||||||||||
| 91 | $self->fail; | ||||||||||||||||||||||||||||
| 92 | 11 | my $right = $self->parse_expression; | |||||||||||||||||||||||||||
| 93 | 11 | ▶ | $self->pop if not $self->done and $self->peek eq ';'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->done and $self->peek eq ";"
MC/DC50%1/2
not $self->done and $self->peek eq ";"
not $self->done
$self->peek eq ";"
Truth table66%2/3
not(A) and B
A= not $self->doneB= $self->peek eq ";"
| |||||||||||||||||||||||||||||
| 94 | 11 | ▶ | $self->fail unless $self->done; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 11 | ▶ | push @{$self->function->statements}, TestML1::Statement->new( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | expr => $left, | ||||||||||||||||||||||||||||
| 98 | assert => TestML1::Assertion->new( | ||||||||||||||||||||||||||||
| 99 | name => $op, | ||||||||||||||||||||||||||||
| 100 | expr => $right, | ||||||||||||||||||||||||||||
| 101 | ), | ||||||||||||||||||||||||||||
| 102 | 11 | @{$self->points} ? (points => $self->points) : (), | |||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||
| 104 | 11 | return 1; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 35 | ▶ | sub parse_expression { | ||||||||||||||||||||||||||
|
Subroutine
parse_expression: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 108 | 35 | my ($self) = @_; | |||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 35 | my $calls = []; | |||||||||||||||||||||||||||
| 111 | 35 | ▶ | while (not $self->done and $self->peek !~ /^($ENDING|$COMP)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->done or $self->peek =~ /^($ENDING|$COMP)$/
MC/DC100%2/2
$self->done or $self->peek =~ /^($ENDING|$COMP)$/
$self->done
$self->peek =~ /^($ENDING|$COMP)$/
Truth table100%3/3
A or B
A= $self->doneB= $self->peek =~ /^($ENDING|$COMP)$/
| |||||||||||||||||||||||||||||
| 112 | 47 | my $token = $self->pop; | |||||||||||||||||||||||||||
| 113 | 47 | ▶ | if ($token =~ /^$NUM$/) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 114 | 4 | push @$calls, TestML1::Num->new(value => $token + 0); | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | elsif ($token =~/^$QSTR$/) { | ||||||||||||||||||||||||||||
| 117 | 10 | my $str = substr($token, 1, length($token) - 2); | |||||||||||||||||||||||||||
| 118 | 10 | push @$calls, TestML1::Str->new(value => $str); | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | elsif ($token =~ /^$WORD$/) { | ||||||||||||||||||||||||||||
| 121 | 16 | my $call = TestML1::Call->new(name => $token); | |||||||||||||||||||||||||||
| 122 | 16 | ▶ | if (not $self->done and $self->peek eq '(') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->done and $self->peek eq "("
MC/DC100%2/2
not $self->done and $self->peek eq "("
not $self->done
$self->peek eq "("
Truth table100%3/3
not(A) and B
A= not $self->doneB= $self->peek eq "("
| |||||||||||||||||||||||||||||
| 123 | 5 | $call->{args} = $self->parse_args; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | 16 | push @$calls, $call; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | elsif ($token =~ /^$POINT$/) { | ||||||||||||||||||||||||||||
| 128 | 17 | ▶ | $token =~ /($WORD)/ or die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | 17 | $token = $1; | |||||||||||||||||||||||||||
| 130 | 17 | $token =~ s/-/_/g; | |||||||||||||||||||||||||||
| 131 | 17 | push @{$self->{points}}, $token; | |||||||||||||||||||||||||||
| 132 | 17 | push @$calls, TestML1::Point->new(name => $token); | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | else { | ||||||||||||||||||||||||||||
| 135 | 0 | $self->fail("Unknown token '$token'"); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 47 | ▶ | if (not $self->done and $self->peek eq '.') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->done and $self->peek eq "."
MC/DC100%2/2
not $self->done and $self->peek eq "."
not $self->done
$self->peek eq "."
Truth table100%3/3
not(A) and B
A= not $self->doneB= $self->peek eq "."
| |||||||||||||||||||||||||||||
| 138 | 12 | $self->pop; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | 35 | ▶ | return @$calls == 1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | ? $calls->[0] | ||||||||||||||||||||||||||||
| 143 | : TestML1::Expression->new(calls => $calls); | ||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 5 | ▶ | sub parse_args { | ||||||||||||||||||||||||||
|
Subroutine
parse_args: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 147 | 5 | my ($self) = @_; | |||||||||||||||||||||||||||
| 148 | 5 | ▶ | $self->pop eq '(' or die; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 149 | 5 | my $args = []; | |||||||||||||||||||||||||||
| 150 | 5 | ▶ | while ($self->peek ne ')') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 7 | push @$args, $self->parse_expression; | |||||||||||||||||||||||||||
| 152 | 7 | ▶ | $self->pop if $self->peek eq ','; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | 5 | $self->pop; | |||||||||||||||||||||||||||
| 155 | 5 | return $args; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 4 | ▶ | sub compile_data { | ||||||||||||||||||||||||||
|
Subroutine
compile_data: called CC=13 SCAR=26.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 159 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||
| 160 | 4 | my $input = $self->data; | |||||||||||||||||||||||||||
| 161 | 4 | $input =~ s/^#.*\n/\n/mg; | |||||||||||||||||||||||||||
| 162 | 4 | my @blocks = grep $_, split /(^$block_marker.*?(?=^$block_marker|\z))/ms, $input; | |||||||||||||||||||||||||||
| 163 | 4 | for my $block (@blocks) { | |||||||||||||||||||||||||||
| 164 | 5 | $block =~ s/\n+\z/\n/; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 4 | my $data = []; | |||||||||||||||||||||||||||
| 168 | 4 | for my $string_block (@blocks) { | |||||||||||||||||||||||||||
| 169 | 5 | my $block = TestML1::Block->new; | |||||||||||||||||||||||||||
| 170 | 5 | ▶ | $string_block =~ s/^$block_marker\ +(.*?)\ *\n//g | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 171 | or die "No block label! $string_block"; | ||||||||||||||||||||||||||||
| 172 | 5 | $block->{label} = $1; | |||||||||||||||||||||||||||
| 173 | 5 | $string_block =~ s/\A(.*?)(^$point_marker\ )/$2/sm; | |||||||||||||||||||||||||||
| 174 | 5 | ▶ | while (length $string_block) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | 14 | ▶ | next if $string_block =~ s/^\n+//; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 176 | 14 | my ($key, $value); | |||||||||||||||||||||||||||
| 177 | 14 | ▶ | if ($string_block =~ s/\A$point_marker\ +($WORD):\ +(.*)\n//g or | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$string_block =~ s/\A$TestML1::Compiler::Lite::point_marker\ +($WORD):\ +(.*)\n//g or $string_block =~ s/\A$TestML1::Compiler::Lite::point_marker\ +($WORD)\n(.*?)(?=^$TestML1::Compiler::Lite::point_marker|\z)//gms
MC/DC0%0/2
$string_block =~ s/\A$TestML1::Compiler::Lite::point_marker\ +($WORD):\ +(.*)\n//g or $string_block =~ s/\A$TestML1::Compiler::Lite::point_marker\ +($WORD)\n(.*?)(?=^$TestML1::Compiler::Lite::point_marker|\z)//gms
$string_block =~ s/\A$TestML1::Compiler::Lite::point_marker\ +($WORD):\ +(.*)\n//g
$string_block =~ s/\A$TestML1::Compiler::Lite::point_marker\ +($WORD)\n(.*?)(?=^$TestML1::Compiler::Lite::point_marker|\z)//gms
Truth table66%2/3
A or B
A= $string_block =~ s/\A$TestML1::Compiler::Lite::point_marker\ +($WORD):\ +(.*)\n//gB= $string_block =~ s/\A$TestML1::Compiler::Lite::point_marker\ +($WORD)\n(.*?)(?=^$TestML1::Compiler::Lite::point_marker|\z)//gms
| |||||||||||||||||||||||||||||
| 178 | $string_block =~ | ||||||||||||||||||||||||||||
| 179 | s/\A$point_marker\ +($WORD)\n(.*?)(?=^$point_marker|\z)//msg | ||||||||||||||||||||||||||||
| 180 | ) { | ||||||||||||||||||||||||||||
| 181 | 14 | ($key, $value) = ($1, $2); | |||||||||||||||||||||||||||
| 182 | 14 | $key =~ s/-/_/g; | |||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||
| 185 | 0 | die "Failed to parse TestML1 string:\n$string_block"; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | 14 | ▶ | $block->{points} ||= {}; | ||||||||||||||||||||||||||
|
Condition100%2/2
$block->{"points"} ||= {}
MC/DC100%1/1
$block->{"points"} ||= {}
$block->{"points"}
Truth table100%2/2
A
A= $block->{"points"}
| |||||||||||||||||||||||||||||
| 188 | 14 | ▶ | my $eol = ($value =~ s/(\r?\n)\s*\z//) ? $1 : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 14 | ▶ | if (length $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 14 | $value .= $eol; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 14 | $block->{points}{$key} = $value; | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 14 | ▶ | if ($key =~ /^(ONLY|SKIP|LAST)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $block->{$key} = 1; | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | 5 | push @$data, $block; | |||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | 4 | ▶ | $self->function->{data} = $data if @$data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 227 | ▶ | sub done { | ||||||||||||||||||||||||||
|
Subroutine
done: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 204 | 227 | my ($self) = @_; | |||||||||||||||||||||||||||
| 205 | 227 | ▶ | @{$self->{tokens}} ? 0 : 1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 151 | ▶ | sub peek { | ||||||||||||||||||||||||||
|
Subroutine
peek: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 209 | 151 | my ($self, $index) = @_; | |||||||||||||||||||||||||||
| 210 | 151 | ▶ | $index ||= 1; | ||||||||||||||||||||||||||
|
Condition100%2/2
$index ||= 1
MC/DC100%1/1
$index ||= 1
$index
Truth table100%2/2
A
A= $index
| |||||||||||||||||||||||||||||
| 211 | 151 | ▶ | die if $index > @{$self->{tokens}}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 151 | $self->{tokens}->[$index - 1]; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 90 | ▶ | sub pop { | ||||||||||||||||||||||||||
|
Subroutine
pop: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 216 | 90 | my ($self, $count) = @_; | |||||||||||||||||||||||||||
| 217 | 90 | ▶ | $count ||= 1; | ||||||||||||||||||||||||||
|
Condition100%2/2
$count ||= 1
MC/DC100%1/1
$count ||= 1
$count
Truth table100%2/2
A
A= $count
| |||||||||||||||||||||||||||||
| 218 | 90 | ▶ | die if $count > @{$self->{tokens}}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 90 | splice @{$self->{tokens}}, 0, $count; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 0 | ▶ | sub fail { | ||||||||||||||||||||||||||
|
Subroutine
fail: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 223 | 0 | my ($self, $message) = @_; | |||||||||||||||||||||||||||
| 224 | 0 | my $text = "Failed to compile TestML1 document.\n"; | |||||||||||||||||||||||||||
| 225 | 0 | ▶ | $text .= "Reason: $message\n" if $message; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 0 | $text .= "\nCode section of failure:\n$self->{line}\n$self->{code}\n"; | |||||||||||||||||||||||||||
| 227 | 0 | die $text; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 5 | 1; | |||||||||||||||||||||||||||