blib/lib/WWW/Shopify/Liquid/Parser.pm

filter: Statementstmt 8.1% 24 / 295 Branchbran 0.0% 0 / 166 Conditioncond 0.0% 0 / 72 MC/DCmcdc 0.0% 0 / 38 Subroutinesub 19.5% 8 / 41 Podpod n/a totaltotal 5.2% 32 / 612 CC 124 SCAR 61.3
CC
124
Cov
5%
parse_argument_tokens
1332.0
parse_inner_tokens
812.0
unparse_tokens
156.0
CRAP 458.4
« blib/lib/WWW/Shopify/Liquid/Tag/Assign.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Operator/Concatenate.pm »
1 #!/usr/bin/perl
2  
3 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package WWW::Shopify::Liquid::Parser;
7 37 ▶use base 'WWW::Shopify::Liquid::Pipeline';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 37 ▶use Module::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 37 ▶use List::MoreUtils qw(firstidx part);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 37 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 37 ▶use WWW::Shopify::Liquid::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 useall WWW::Shopify::Liquid::Operator;
14 useall WWW::Shopify::Liquid::Tag;
15 useall WWW::Shopify::Liquid::Filter;
16  
17 0 ▶sub new { return bless {
Subroutine new: not called CC=1 SCAR=6.9
18 # Internal
19 order_of_operations => [],
20 operators => {},
21 enclosing_tags => {},
22 free_tags => {},
23 filters => {},
24 inner_tags => {},
25 security => WWW::Shopify::Liquid::Security->new,
26
27 # Determines whether or not we should error on finding a filter we don't recognize. Can be useful for parsing, without actually rendering ot have this on.
28 # No tag version, because we need to know whether a tag is free or enclosing to parse correctly.
29 accept_unknown_filters => 0,
30 # Determines whether we clear the custom tag/filter cache after each parse. For security purposes, should be true by default,
31 # or custom tags should be disabled entirely.
32 transient_custom_operations => 1,
33 custom_tags => {},
34 custom_filters => {},
35 transient_elements => []
36 }, $_[0]; }
37 0 ▶sub accept_unknown_filters { $_[0]->{accept_unknown_filters} = $_[1] if defined $_[1]; return $_[0]->{accept_unknown_filters}; }
Subroutine accept_unknown_filters: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
38 0 ▶sub accept_method_calls { $_[0]->{accept_method_calls} = $_[1] if defined $_[1]; return $_[0]->{accept_method_calls}; }
Subroutine accept_method_calls: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
39 0 ▶sub transient_custom_operations { $_[0]->{transient_custom_operations} = $_[1] if defined $_[1]; return $_[0]->{transient_custom_operations}; }
Subroutine transient_custom_operations: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[1] 0 0 0
40 0 ▶sub custom_tags { return $_[0]->{custom_tags}; }
Subroutine custom_tags: not called CC=1 SCAR=6.9
41 0 ▶sub custom_filters { return $_[0]->{custom_filters}; }
Subroutine custom_filters: not called CC=1 SCAR=6.9
42 0 ▶sub operator { return $_[0]->{operators}->{$_[1]}; }
Subroutine operator: not called CC=1 SCAR=6.9
43 0 ▶sub operators { return $_[0]->{operators}; }
Subroutine operators: not called CC=1 SCAR=6.9
44 0 ▶sub order_of_operations { return @{$_[0]->{order_of_operations}}; }
Subroutine order_of_operations: not called CC=1 SCAR=6.9
45 0 ▶sub free_tags { return $_[0]->{free_tags}; }
Subroutine free_tags: not called CC=1 SCAR=6.9
46 0 ▶sub enclosing_tags { return $_[0]->{enclosing_tags}; }
Subroutine enclosing_tags: not called CC=1 SCAR=6.9
47 0 ▶sub inner_tags { return $_[0]->{inner_tags}; }
Subroutine inner_tags: not called CC=1 SCAR=6.9
48 0 ▶sub filters { return $_[0]->{filters}; }
Subroutine filters: not called CC=1 SCAR=6.9
49  
50 sub register_tag {
51 0 ▶ my ($self, $tag) = @_;
Subroutine register_tag: not called CC=4 SCAR=30.0
52 0 $self->SUPER::register_tag($tag);
53 0 ▶ $self->free_tags->{$tag->name} = $tag if $tag->is_free;
Branch: 1 branch
BranchTrueFalseTotal
if $tag->is_free 0 0 0
54 0 ▶ if ($tag->is_enclosing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->is_enclosing) 0 0 0
55 0 $self->enclosing_tags->{$tag->name} = $tag;
56 0 foreach my $inner_tag ($tag->inner_tags) {
57 0 $self->inner_tags->{$inner_tag} = 1;
58 }
59 }
60 }
61  
62 sub register_operator {
63 0 ▶ $_[0]->SUPER::register_operator($_[1]);
Subroutine register_operator: not called CC=3 SCAR=24.8
64 0 $_[0]->operators->{$_} = $_[1] for($_[1]->symbol);
65 0 my $ooo = $_[0]->{order_of_operations};
66 0 ▶ my $element = first { $_->[0]->priority == $_[1]->priority } @$ooo;
Subroutine __ANON__: not called CC=1 SCAR=6.9
67 0 ▶ if ($element) {
Branch: 1 branch
BranchTrueFalseTotal
if ($element) { } 0 0 0
68 0 push(@$element, $_[1]);
69 }
70 else {
71 0 push(@$ooo, [$_[1]]);
72 }
73 0 $_[0]->{order_of_operations} = [sort { $b->[0]->priority <=> $a->[0]->priority } @$ooo];
74 }
75 sub register_filter {
76 0 ▶ $_[0]->SUPER::register_filter($_[1]);
Subroutine register_filter: not called CC=1 SCAR=6.9
77 0 $_[0]->filters->{$_[1]->name} = $_[1];
78 }
79  
80 sub deregister_tag {
81 0 ▶ my ($self, $tag) = @_;
Subroutine deregister_tag: not called CC=6 SCAR=37.4
82 0 $self->SUPER::deregister_tag($tag);
83 0 ▶ if ($tag->is_enclosing) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag->is_enclosing) { } 0 0 0
84 0 ▶ delete $self->enclosing_tags->{$tag->name} if $self->enclosing_tags->{$tag->name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->enclosing_tags->{$tag->name} 0 0 0
85 0 foreach my $inner_tag ($tag->inner_tags) {
86 0 ▶ delete $self->inner_tags->{$inner_tag} if $self->inner_tags->{$inner_tag};
Branch: 1 branch
BranchTrueFalseTotal
if $self->inner_tags->{$inner_tag} 0 0 0
87 }
88 } else {
89 0 ▶ delete $self->free_tags->{$tag->name} if $self->free_tags->{$tag->name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->free_tags->{$tag->name} 0 0 0
90 }
91 }
92 sub deregister_filter {
93 0 ▶ my ($self, $filter) = @_;
Subroutine deregister_filter: not called CC=2 SCAR=17.9
94 0 $self->SUPER::deregister_filter($filter);
95 0 ▶ delete $self->filters->{$filter->name} if $self->filters->{$filter->name};
Branch: 1 branch
BranchTrueFalseTotal
if $self->filters->{$filter->name} 0 0 0
96 }
97  
98  
99 sub parse_filter_tokens {
100 0 ▶ my ($self, $initial, @tokens) = @_;
Subroutine parse_filter_tokens: not called CC=10 SCAR=47.0
101 0 my $filter = shift(@tokens);
102 0 ▶ my $filter_name = $filter->isa('WWW::Shopify::Liquid::Token::Operator') ? $filter->{core} : $filter->{core}->[0]->{core};
Branch: 1 branch
BranchTrueFalseTotal
$filter->isa('WWW::Shopify::Liquid::Token::Operator') ? : 0 0 0
103 # TODO God, this is stupid, but temporary patch.
104 0 my $filter_package;
105 0 ▶ if ($filter_name =~ m/::/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filter_name =~ /::/) { } 0 0 0
106 0 $filter_package = $filter_name;
107 0 eval { $filter_package->name };
108 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
109 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::UnknownFilter($filter) if !$self->accept_unknown_filters;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->accept_unknown_filters 0 0 0
110 0 $filter_package = 'WWW::Shopify::Liquid::Filter::Unknown';
111 }
112 } else {
113 0 ▶ if (!$self->{filters}->{$filter_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'filters'}{$filter_name}) { } 0 0 0
114 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::UnknownFilter($filter) if !$self->accept_unknown_filters;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->accept_unknown_filters 0 0 0
115 0 $filter_package = 'WWW::Shopify::Liquid::Filter::Unknown';
116 } else {
117 0 $filter_package = $self->{filters}->{$filter_name};
118 }
119 }
120 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::Arguments($filter, "In order to have arguments, filter must be followed by a colon.") if int(@tokens) > 0 && $tokens[0]->{core} ne ":";
Branch: 1 branch
BranchTrueFalseTotal
if int @tokens > 0 and $tokens[0]{"core"} ne ":" 0 0 0
Condition0%0/3
int @tokens > 0 and $tokens[0]{"core"} ne ":"
!ll&&!rl&&r
000
MC/DC0%0/2
int @tokens > 0 and $tokens[0]{"core"} ne ":"
int @tokens > 0 $tokens[0]{"core"} ne ":"
Truth table0%0/3
A and B
A= int @tokens > 0B= $tokens[0]{"core"} ne ":"
ABresult
0X0
100
111
121
122 0 my @arguments = ();
123 # Get rid of our colon.
124 0 ▶ if (shift(@tokens)) {
Branch: 1 branch
BranchTrueFalseTotal
if (shift @tokens) 0 0 0
125 0 my $i = 0;
126 0 ▶ @arguments = map { $self->parse_argument_tokens(grep { !$_->isa('WWW::Shopify::Liquid::Token::Separator') } @{$_}) } part { $i++ if $_->isa('WWW::Shopify::Liquid::Token::Separator') && $_->{core} eq ","; $i; } @tokens;
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
if $_->isa("WWW::Shopify::Liquid::Token::Separator") and $_->{"core"} eq "," 0 0 0
Condition0%0/3
$_->isa("WWW::Shopify::Liquid::Token::Separator") and $_->{"core"} eq ","
!ll&&!rl&&r
000
MC/DC0%0/2
$_->isa("WWW::Shopify::Liquid::Token::Separator") and $_->{"core"} eq ","
$_->isa("WWW::Shopify::Liquid::Token::Separator") $_->{"core"} eq ","
Truth table0%0/3
A and B
A= $_->isa("WWW::Shopify::Liquid::Token::Separator")B= $_->{"core"} eq ","
ABresult
0X0
100
111
127 }
128 0 $filter = $filter_package->new($self, $filter->{line}, $filter_name, $initial, @arguments);
129 0 $filter->verify($self);
130 0 return $filter;
131 }
132 37 ▶use List::MoreUtils qw(part);
Subroutine BEGIN: called CC=1 SCAR=0.0
133  
134 sub walk_groupings {
135 0 ▶ my ($self, $aggregate) = @_;
Subroutine walk_groupings: not called CC=4 SCAR=30.0
136 0 for (grep {
137 0 $aggregate->{members}->[$_]->isa('WWW::Shopify::Liquid::Token::Grouping')
138 0 } 0..(int(@{$aggregate->{members}})-1)) {
139 0 ($aggregate->{members}->[$_]) = $self->parse_argument_tokens($aggregate->{members}->[$_]->members);
140 }
141 0 ▶ $self->walk_groupings($_) for (grep { $_->isa('WWW::Shopify::Liquid::Token::Hash') || $_->isa('WWW::Shopify::Liquid::Token::Array') } $aggregate->members);
Branch: 1 branch
BranchTrueFalseTotal
$_->isa("WWW::Shopify::Liquid::Token::Hash") or $_->isa("WWW::Shopify::Liquid::Token::Array") 0 0 0
142
143 }
144  
145 # Similar, but doesn't deal with tags; deals solely with order of operations.
146 sub parse_argument_tokens {
147 0 ▶ my ($self, @argument_tokens) = @_;
Subroutine parse_argument_tokens: not called CC=36 SCAR=71.9
148
149 # Process all function calls. That means groupings, preceded by a varialbe.
150 my @ids = grep {
151 0 ▶ $argument_tokens[$_]->isa('WWW::Shopify::Liquid::Token::Variable') && $argument_tokens[$_+1]->isa('WWW::Shopify::Liquid::Token::Grouping')
Branch: 1 branch
BranchTrueFalseTotal
$argument_tokens[$_]->isa("WWW::Shopify::Liquid::Token::Variable") and $argument_tokens[$_ + 1]->isa("WWW::Shopify::Liquid::Token::Grouping") 0 0 0
152 } (0..$#argument_tokens-1);
153 0 for (@ids) {
154 0 $argument_tokens[$_] = WWW::Shopify::Liquid::Token::FunctionCall->new($argument_tokens[$_]->{line}, pop(@{$argument_tokens[$_]->{core}}), $argument_tokens[$_], $self->parse_argument_tokens($argument_tokens[$_+1]->members));
155 0 $argument_tokens[$_+1] = undef;
156 }
157 0 @argument_tokens = grep { defined $_ } @argument_tokens;
158
159 # Process all groupings.
160 0 ($argument_tokens[$_]) = $self->parse_argument_tokens($argument_tokens[$_]->members) for (grep { $argument_tokens[$_]->isa('WWW::Shopify::Liquid::Token::Grouping') } 0..$#argument_tokens);
161
162 # Process all groupings inside named variables.
163 0 ▶ ($_->{core}) = $self->parse_argument_tokens($_->{core}->members) for (grep { $_->isa('WWW::Shopify::Liquid::Token::Variable::Named') && $_->{core}->isa('WWW::Shopify::Liquid::Token::Grouping') } @argument_tokens);
Branch: 1 branch
BranchTrueFalseTotal
$_->isa("WWW::Shopify::Liquid::Token::Variable::Named") and $_->{"core"}->isa("WWW::Shopify::Liquid::Token::Grouping") 0 0 0
164 # Preprocess all variant filters.
165 0 for my $variable (grep { $_->isa('WWW::Shopify::Liquid::Token::Variable') } @argument_tokens) {
166 0 my @core = @{$variable->{core}};
167 0 ($variable->{core}->[$_]) = $self->parse_argument_tokens($core[$_]->members) for (grep { $core[$_]->isa('WWW::Shopify::Liquid::Token::Grouping') } 0..$#core);
168 }
169
170 # Every member that's a grouping inside of the hash should be evaluated.
171 0 ▶ $self->walk_groupings($_) for (grep { $_->isa('WWW::Shopify::Liquid::Token::Hash') || $_->isa('WWW::Shopify::Liquid::Token::Array') } @argument_tokens);
Branch: 1 branch
BranchTrueFalseTotal
$_->isa("WWW::Shopify::Liquid::Token::Hash") or $_->isa("WWW::Shopify::Liquid::Token::Array") 0 0 0
172
173 # Process unary operators first; these have highest priority, regardless of what the priority field says.
174 0 ▶ while ((my $idx = firstidx { $_->isa('WWW::Shopify::Liquid::Token::Operator') && defined $_->{core} && $self->operator($_->{core}) && $self->operator($_->{core})->arity eq "unary" } @argument_tokens) != -1) {
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 2 branches
BranchTrueFalseTotal
if ((my $idx = &firstidx(sub { $_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"} and $self->operator($_->{"core"}) and $self->operator($_->{"core"})->arity eq "unary"; } , @argument_tokens)) != -1) 0 0 0
$_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"} and $self->operator($_->{"core"}) and $self->operator($_->{"core"})->arity eq "unary" 0 0 0
Condition0%0/6
$_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"} and $self->operator($_->{"core"})
!ll&&!rl&&r
000
$_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"}
!ll&&!rl&&r
000
MC/DC0%0/3
$_->isa("WWW::Shopify::Liquid::Token::Operator") and defined $_->{"core"} and $self->operator($_->{"core"})
$_->isa("WWW::Shopify::Liquid::Token::Operator") defined $_->{"core"} $self->operator($_->{"core"})
Truth table0%0/4
A and B and C
A= $_->isa("WWW::Shopify::Liquid::Token::Operator")B= defined $_->{"core"}C= $self->operator($_->{"core"})
ABCresult
0XX0
10X0
1100
1111
175 0 my $op = $argument_tokens[$idx];
176 0 my $fixness = $self->operator($argument_tokens[$idx]->{core})->fixness;
177 0 ▶ my $op1 = $fixness eq "postfix" ? $argument_tokens[$idx-1] : $argument_tokens[$idx+1];
Branch: 1 branch
BranchTrueFalseTotal
$fixness eq 'postfix' ? : 0 0 0
178 0 ▶ my $start = $fixness eq "potsfix" ? $idx-1 : $idx;
Branch: 1 branch
BranchTrueFalseTotal
$fixness eq 'potsfix' ? : 0 0 0
179 0 splice(@argument_tokens, $start, 2, $self->operator($argument_tokens[$idx]->{core})->new($op->{line}, $op->{core}, $op1));
180 }
181
182 # First, pull together filters. These are the highest priority operators, after parentheses. They also have their own weird syntax.
183 0 my $top = undef;
184
185 # Don't partition if we have any pipes. Pipes and multiple arguments don't play well together.
186 0 my @partitions;
187 0 my $has_pipe = 0;
188 0 ▶ if (int(grep { $_->isa('WWW::Shopify::Liquid::Token::Operator') && $_->{core} eq "|" } @argument_tokens) == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (int grep({$_->isa('WWW::Shopify::Liquid::Token::Operator') and $_->{'core'} eq '|';} @argument_tokens) == 0) { } 0 0 0
$_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|" 0 0 0
189 0 my $i = 0;
190 0 $has_pipe = 1;
191 0 ▶ @partitions = part { $i++ if $_->isa('WWW::Shopify::Liquid::Token::Separator'); $i; } @argument_tokens;
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $_->isa("WWW::Shopify::Liquid::Token::Separator") 0 0 0
192 0 @partitions = map { my @n = grep { !$_->isa('WWW::Shopify::Liquid::Token::Separator') } @$_; \@n } @partitions;
193 } else {
194 0 @partitions = (\@argument_tokens);
195 }
196
197
198
199 0 my @tops;
200
201
202
203 0 foreach my $partition (@partitions) {
204 0 my @tokens = @$partition;
205 #@tokens = (grep { !$_->isa('WWW::Shopify::Liquid::Token::Separator') } @tokens) if !$has_pipe;
206
207 # Use the order of operations to create a binary tree structure.
208 0 foreach my $operators ($self->order_of_operations) {
209 0 my %ops = map { $_ => 1 } map { $_->symbol } @$operators;
210 # If we have pipes, we deal with those, and parse their lower level arguments first; this is an exception. Rewrite?
211 0 ▶ if ($operators->[0] eq 'WWW::Shopify::Liquid::Operator::Pipe') {
Branch: 1 branch
BranchTrueFalseTotal
if ($operators->[0] eq 'WWW::Shopify::Liquid::Operator::Pipe') { } 0 0 0
212 0 ▶ if ((my $idx = firstidx { $_->isa('WWW::Shopify::Liquid::Token::Operator') && $_->{core} eq "|" } @tokens) != -1) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 2 branches
BranchTrueFalseTotal
if ((my $idx = &firstidx(sub { $_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|"; } , @tokens)) != -1) 0 0 0
$_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|" 0 0 0
213 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser($tokens[0]) if $idx == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $idx == 0 0 0 0
214 0 my $i = 0;
215 # Part should consist of the first token before a pipe, and then split on all pipes after this.,
216 0 ▶ my @parts = map { shift(@{$_}) if $_->[0]->{core} && $_->[0]->{core} eq "|"; $_ } part { $i++ if $_->isa('WWW::Shopify::Liquid::Token::Operator') && $_->{core} eq "|"; $i; } splice(@tokens, $idx-1);
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
if $_->[0]{"core"} and $_->[0]{"core"} eq "|" 0 0 0
if $_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|" 0 0 0
Condition0%0/6
$_->[0]{"core"} and $_->[0]{"core"} eq "|"
!ll&&!rl&&r
000
$_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|"
!ll&&!rl&&r
000
MC/DC0%0/2
$_->[0]{"core"} and $_->[0]{"core"} eq "|"
$_->[0]{"core"} $_->[0]{"core"} eq "|"
MC/DC0%0/2
$_->isa("WWW::Shopify::Liquid::Token::Operator") and $_->{"core"} eq "|"
$_->isa("WWW::Shopify::Liquid::Token::Operator") $_->{"core"} eq "|"
Truth table0%0/3
A and B
A= $_->[0]{"core"}B= $_->[0]{"core"} eq "|"
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $_->isa("WWW::Shopify::Liquid::Token::Operator")B= $_->{"core"} eq "|"
ABresult
0X0
100
111
217 0 my $next = undef;
218 0 $top = $self->parse_filter_tokens($self->parse_argument_tokens(@{shift(@parts)}), @{shift(@parts)});
219 0 ▶ while (my $part = shift(@parts)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $part = shift @parts) 0 0 0
220 0 $top = $self->parse_filter_tokens($top, @$part);
221 }
222 0 push(@tokens, $top);
223 }
224 } else {
225 0 ▶ while ((my $idx = firstidx { $_->isa('WWW::Shopify::Liquid::Token::Operator') && exists $ops{$_->{core}} } @tokens) != -1) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 2 branches
BranchTrueFalseTotal
if ((my $idx = &firstidx(sub { $_->isa("WWW::Shopify::Liquid::Token::Operator") and exists $ops{$_->{"core"}}; } , @tokens)) != -1) 0 0 0
$_->isa("WWW::Shopify::Liquid::Token::Operator") and exists $ops{$_->{"core"}} 0 0 0
226 0 my ($op1, $op, $op2) = @tokens[$idx-1..$idx+1];
227 # The one exception would be if we have a - operator, and nothing before, this is unary negative operator, i.e. 0 - number.
228 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::Operands($op, $op1, $op, $op2) unless
Branch: 1 branch
BranchTrueFalseTotal
unless $idx > 0 and $idx < $#tokens and $op1->isa("WWW::Shopify::Liquid::Operator") || $op1->isa("WWW::Shopify::Liquid::Token::Operand") || $op1->isa("WWW::Shopify::Liquid::Filter") and $op2->isa("WWW::Shopify::Liquid::Operator") || $op2->isa("WWW::Shopify::Liquid::Token::Operand") || $op2->isa("WWW::Shopify::Liquid::Filter") 0 0 0
Condition0%0/21
$idx > 0 and $idx < $#tokens and $op1->isa("WWW::Shopify::Liquid::Operator") || $op1->isa("WWW::Shopify::Liquid::Token::Operand") || $op1->isa("WWW::Shopify::Liquid::Filter") and $op2->isa("WWW::Shopify::Liquid::Operator") || $op2->isa("WWW::Shopify::Liquid::Token::Operand") || $op2->isa("WWW::Shopify::Liquid::Filter")
!ll&&!rl&&r
000
$idx > 0 and $idx < $#tokens and $op1->isa("WWW::Shopify::Liquid::Operator") || $op1->isa("WWW::Shopify::Liquid::Token::Operand") || $op1->isa("WWW::Shopify::Liquid::Filter")
!ll&&!rl&&r
000
$idx > 0 and $idx < $#tokens
!ll&&!rl&&r
000
$op1->isa("WWW::Shopify::Liquid::Operator") or $op1->isa("WWW::Shopify::Liquid::Token::Operand") or $op1->isa("WWW::Shopify::Liquid::Filter")
l!l&&r!l&&!r
000
$op1->isa("WWW::Shopify::Liquid::Operator") or $op1->isa("WWW::Shopify::Liquid::Token::Operand")
l!l&&r!l&&!r
000
$op2->isa("WWW::Shopify::Liquid::Operator") or $op2->isa("WWW::Shopify::Liquid::Token::Operand") or $op2->isa("WWW::Shopify::Liquid::Filter")
l!l&&r!l&&!r
000
$op2->isa("WWW::Shopify::Liquid::Operator") or $op2->isa("WWW::Shopify::Liquid::Token::Operand")
l!l&&r!l&&!r
000
MC/DC0%0/8
$idx > 0 and $idx < $#tokens and $op1->isa("WWW::Shopify::Liquid::Operator") || $op1->isa("WWW::Shopify::Liquid::Token::Operand") || $op1->isa("WWW::Shopify::Liquid::Filter") and $op2->isa("WWW::Shopify::Liquid::Operator") || $op2->isa("WWW::Shopify::Liquid::Token::Operand") || $op2->isa("WWW::Shopify::Liquid::Filter")
$idx > 0 $idx < $#tokens $op1->isa("WWW::Shopify::Liquid::Operator") $op1->isa("WWW::Shopify::Liquid::Token::Operand") $op1->isa("WWW::Shopify::Liquid::Filter") $op2->isa("WWW::Shopify::Liquid::Operator") $op2->isa("WWW::Shopify::Liquid::Token::Operand") $op2->isa("WWW::Shopify::Liquid::Filter")
Truth table0%0/15
A and B and C or D or E and F or G or H
A= $idx > 0B= $idx < $#tokensC= $op1->isa("WWW::Shopify::Liquid::Operator")D= $op1->isa("WWW::Shopify::Liquid::Token::Operand")E= $op1->isa("WWW::Shopify::Liquid::Filter")F= $op2->isa("WWW::Shopify::Liquid::Operator")G= $op2->isa("WWW::Shopify::Liquid::Token::Operand")H= $op2->isa("WWW::Shopify::Liquid::Filter")
ABCDEFGHresult
0XXXXXXX0
10XXXXXX0
11000XXX0
111XX0000
1101X0000
110010000
111XX1XX1
111XX01X1
111XX0011
1101X1XX1
1101X01X1
1101X0011
110011XX1
1100101X1
110010011
229 $idx > 0 && $idx < $#tokens &&
230 ($op1->isa('WWW::Shopify::Liquid::Operator') || $op1->isa('WWW::Shopify::Liquid::Token::Operand') || $op1->isa('WWW::Shopify::Liquid::Filter')) &&
231 ($op2->isa('WWW::Shopify::Liquid::Operator') || $op2->isa('WWW::Shopify::Liquid::Token::Operand') || $op2->isa('WWW::Shopify::Liquid::Filter'));
232 0 ▶ ($op1) = $self->parse_argument_tokens($op1->members) if $op1->isa('WWW::Shopify::Liquid::Token::Grouping');
Branch: 1 branch
BranchTrueFalseTotal
if $op1->isa("WWW::Shopify::Liquid::Token::Grouping") 0 0 0
233 0 ▶ ($op2) = $self->parse_argument_tokens($op2->members) if $op2->isa('WWW::Shopify::Liquid::Token::Grouping');
Branch: 1 branch
BranchTrueFalseTotal
if $op2->isa("WWW::Shopify::Liquid::Token::Grouping") 0 0 0
234 0 splice(@tokens, $idx-1, 3, $self->operators->{$op->{core}}->new($op->{line}, $op->{core}, $op1, $op2));
235 }
236 }
237 }
238
239 # Only named variables can be without commas, for whatever reason. Goddammit shopify.
240 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::Operands(@tokens) unless int(grep { !$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') } @tokens) == 1 || int(grep { !$_->isa('WWW::Shopify::Liquid::Token::Variable::Named') } @tokens) == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1 or int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0 0 0 0
Condition0%0/3
int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1 or int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1 or int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0
int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1 int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0
Truth table0%0/3
A or B
A= int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 1B= int grep({not $_->isa("WWW::Shopify::Liquid::Token::Variable::Named");} @tokens) == 0
ABresult
1X1
011
000
241 0 push(@tops, @tokens);
242 }
243
244 0 return @tops;
245 }
246  
247  
248 sub parse_inner_tokens {
249 0 ▶ my ($self, @tokens) = @_;
Subroutine parse_inner_tokens: not called CC=28 SCAR=67.0
250
251 0 ▶ return () if int(@tokens) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if int @tokens == 0 0 0 0
252
253 0 my @tags = ();
254 # First we take a look and start matching up opening and ending tags. Those which are free tags we can leave as is.
255 0 ▶ while (my $token = shift(@tokens)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = shift @tokens) 0 0 0
256 0 my $line = $token->{line};
257 0 ▶ if ($token->isa('WWW::Shopify::Liquid::Token::Tag')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->isa('WWW::Shopify::Liquid::Token::Tag')) { } 0 0 0
elsif ($token->isa('WWW::Shopify::Liquid::Token::Output')) { } 0 0 0
258 0 my $tag = undef;
259 0 ▶ if ($self->enclosing_tags->{$token->tag}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->enclosing_tags->{$token->tag}) { } 0 0 0
elsif ($self->free_tags->{$token->tag}) { } 0 0 0
260 0 my @internal = ();
261 0 my @contents = ();
262 0 my %allowed_internal_tags = map { $_ => 1 } $self->enclosing_tags->{$token->tag}->inner_tags;
263 0 my $level = 1;
264 0 my $closed = undef;
265 0 for (0..$#tokens) {
266 0 ▶ if ($tokens[$_]->isa('WWW::Shopify::Liquid::Token::Tag')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tokens[$_]->isa("WWW::Shopify::Liquid::Token::Tag")) 0 0 0
267 0 ▶ if ($self->enclosing_tags->{$tokens[$_]->tag}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->enclosing_tags->{$tokens[$_]->tag}) { } 0 0 0
elsif (exists $allowed_internal_tags{$tokens[$_]->tag} and $level == 1) { } 0 0 0
elsif ($tokens[$_]->tag eq 'end' . $token->tag and $level == 1) { } 0 0 0
elsif ($tokens[$_]->tag =~ /^end/) { } 0 0 0
268 0 ++$level;
269 ▶ } elsif (exists $allowed_internal_tags{$tokens[$_]->tag} && $level == 1) {
Condition0%0/3
exists $allowed_internal_tags{$tokens[$_]->tag} and $level == 1
!ll&&!rl&&r
000
MC/DC0%0/2
exists $allowed_internal_tags{$tokens[$_]->tag} and $level == 1
exists $allowed_internal_tags{$tokens[$_]->tag} $level == 1
Truth table0%0/3
A and B
A= exists $allowed_internal_tags{$tokens[$_]->tag}B= $level == 1
ABresult
0X0
100
111
270 0 $tokens[$_]->{arguments} = [$self->parse_argument_tokens(@{$tokens[$_]->{arguments}})];
271 0 push(@internal, $_);
272 ▶ } elsif ($tokens[$_]->tag eq "end" . $token->tag && $level == 1) {
Condition0%0/3
$tokens[$_]->tag eq 'end' . $token->tag and $level == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$tokens[$_]->tag eq 'end' . $token->tag and $level == 1
$tokens[$_]->tag eq 'end' . $token->tag $level == 1
Truth table0%0/3
A and B
A= $tokens[$_]->tag eq 'end' . $token->tagB= $level == 1
ABresult
0X0
100
111
273 0 --$level;
274 0 my $last_int = 0;
275 0 foreach my $int (@internal, $_) {
276 0 push(@contents, [splice(@tokens, 0, $int-$last_int)]);
277 0 ▶ shift(@{$contents[0]}) if $self->enclosing_tags->{$token->tag}->inner_ignore_whitespace && int(@contents) > 0 && int(@{$contents[0]}) > 0 && $contents[0]->[0]->isa('WWW::Shopify::Liquid::Token::Text::Whitespace');
Branch: 1 branch
BranchTrueFalseTotal
if $self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0 and int @{$contents[0];} > 0 and $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace") 0 0 0
Condition0%0/9
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0 and int @{$contents[0];} > 0 and $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace")
!ll&&!rl&&r
000
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0 and int @{$contents[0];} > 0
!ll&&!rl&&r
000
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0
!ll&&!rl&&r
000
MC/DC0%0/4
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace and int @contents > 0 and int @{$contents[0];} > 0 and $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace")
$self->enclosing_tags->{$token->tag}->inner_ignore_whitespace int @contents > 0 int @{$contents[0];} > 0 $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace")
Truth table0%0/5
A and B and C and D
A= $self->enclosing_tags->{$token->tag}->inner_ignore_whitespaceB= int @contents > 0C= int @{$contents[0];} > 0D= $contents[0][0]->isa("WWW::Shopify::Liquid::Token::Text::Whitespace")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
278 @contents = map {
279 0 my @array = @$_;
280 0 ▶ if (int(@array) > 0 && $array[0]->isa('WWW::Shopify::Liquid::Token::Tag') && $allowed_internal_tags{$array[0]->tag}) {
Branch: 1 branch
BranchTrueFalseTotal
if (int @array > 0 and $array[0]->isa('WWW::Shopify::Liquid::Token::Tag') and $allowed_internal_tags{$array[0]->tag}) { } 0 0 0
Condition0%0/6
int @array > 0 and $array[0]->isa("WWW::Shopify::Liquid::Token::Tag") and $allowed_internal_tags{$array[0]->tag}
!ll&&!rl&&r
000
int @array > 0 and $array[0]->isa("WWW::Shopify::Liquid::Token::Tag")
!ll&&!rl&&r
000
MC/DC0%0/3
int @array > 0 and $array[0]->isa("WWW::Shopify::Liquid::Token::Tag") and $allowed_internal_tags{$array[0]->tag}
int @array > 0 $array[0]->isa("WWW::Shopify::Liquid::Token::Tag") $allowed_internal_tags{$array[0]->tag}
Truth table0%0/4
A and B and C
A= int @array > 0B= $array[0]->isa("WWW::Shopify::Liquid::Token::Tag")C= $allowed_internal_tags{$array[0]->tag}
ABCresult
0XX0
10X0
1100
1111
281 0 [$array[0], $self->parse_inner_tokens(@array[1..$#array])];
282 }
283 else {
284 0 [$self->parse_inner_tokens(@array)]
285 }
286 } @contents;
287 0 $last_int = $int;
288 }
289 # Remove the endtag.
290 0 shift(@tokens);
291 0 $closed = 1;
292 0 last;
293 } elsif ($tokens[$_]->tag =~ m/^end/) {
294 0 --$level;
295 # TODO: Fix this whole thing; right now, no close tags are being spit out for the wrong tag. We do this to avoid an {% unless %}{% if %}{% else %}{% endif %}{% endunless%} situtation.
296 }
297 }
298 }
299 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::NoClose($token) unless $closed;
Branch: 1 branch
BranchTrueFalseTotal
unless $closed 0 0 0
300 0 $tag = $self->enclosing_tags->{$token->tag}->new($line, $token->tag, [$self->parse_argument_tokens(@{$token->{arguments}})], \@contents, $self);
301 0 $tag->verify($self);
302 }
303 elsif ($self->free_tags->{$token->tag}) {
304 0 $tag = $self->free_tags->{$token->tag}->new($line, $token->tag, [$self->parse_argument_tokens(@{$token->{arguments}})], undef, $self);
305 0 $tag->verify($self);
306 }
307 else {
308 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::NoOpen($token) if ($token->tag =~ m/^end(\w+)$/ && $self->enclosing_tags->{$1});
Branch: 1 branch
BranchTrueFalseTotal
if $token->tag =~ /^end(\w+)$/ and $self->enclosing_tags->{$1} 0 0 0
Condition0%0/3
$token->tag =~ /^end(\w+)$/ and $self->enclosing_tags->{$1}
!ll&&!rl&&r
000
MC/DC0%0/2
$token->tag =~ /^end(\w+)$/ and $self->enclosing_tags->{$1}
$token->tag =~ /^end(\w+)$/ $self->enclosing_tags->{$1}
Truth table0%0/3
A and B
A= $token->tag =~ /^end(\w+)$/B= $self->enclosing_tags->{$1}
ABresult
0X0
100
111
309 0 ▶ die new WWW::Shopify::Liquid::Exception::Parser::NakedInnerTag($token) if (exists $self->inner_tags->{$token->tag});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->inner_tags->{$token->tag} 0 0 0
310 0 die new WWW::Shopify::Liquid::Exception::Parser::UnknownTag($token);
311 }
312 0 push(@tags, $tag);
313 }
314 elsif ($token->isa('WWW::Shopify::Liquid::Token::Output')) {
315 0 push(@tags, WWW::Shopify::Liquid::Tag::Output->new($line, [$self->parse_argument_tokens(@{$token->{core}})]));
316 }
317 else {
318 0 push(@tags, $token);
319 }
320 }
321
322 0 my $top = undef;
323 0 ▶ if (int(@tags) > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (int @tags > 1) { } 0 0 0
324 0 $top = WWW::Shopify::Liquid::Operator::Concatenate->new($tags[0]->{line}, '', @tags);
325 }
326 else {
327 0 ($top) = @tags;
328 }
329 0 return $top;
330 }
331  
332 sub parse_tokens {
333 0 ▶ my ($self, @tokens) = @_;
Subroutine parse_tokens: not called CC=4 SCAR=30.0
334 0 my $ast = $self->parse_inner_tokens(@tokens);
335 0 for (@{$self->{transient_elements}}) {
336 0 ▶ if ($_->isa('WWW::Shopify::Liquid::Tag')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->isa('WWW::Shopify::Liquid::Tag')) { } 0 0 0
elsif ($_->isa('WWW::Shopify::Liquid::Filter')) { } 0 0 0
337 0 $self->deregister_tag($_);
338 } elsif ($_->isa('WWW::Shopify::Liquid::Filter')) {
339 0 $self->deregister_filter($_);
340 }
341 }
342 0 $self->{transient_elements} = [];
343 0 return $ast;
344 }
345  
346 sub unparse_argument_tokens {
347 0 ▶ my ($self, $ast) = @_;
Subroutine unparse_argument_tokens: not called CC=8 SCAR=42.8
348 0 ▶ return $ast if $self->is_processed($ast);
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_processed($ast) 0 0 0
349 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Filter')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ast->isa('WWW::Shopify::Liquid::Filter')) { } 0 0 0
elsif ($ast->isa('WWW::Shopify::Liquid::Operator')) { } 0 0 0
350 my @optokens = ($self->unparse_argument_tokens($ast->{operand}),
351 WWW::Shopify::Liquid::Token::Operator->new([0,0,0], '|'),
352 ($ast->transparent ? WWW::Shopify::Liquid::Token::Variable->new([0,0,0], WWW::Shopify::Liquid::Token::String->new([0,0,0], $ast->{core}->name)) : WWW::Shopify::Liquid::Token::Variable->new([0,0,0], WWW::Shopify::Liquid::Token::String->new([0,0,0], $ast->{core}))),
353 0 ▶ (int(@{$ast->{arguments}}) > 0 ? (do {
Branch: 2 branches
BranchTrueFalseTotal
$ast->transparent ? : 0 0 0
int @{$ast->{'arguments'};} > 0 ? : 0 0 0
354 0 my @args = @{$ast->{arguments}};
355 (
356 WWW::Shopify::Liquid::Token::Separator->new([0,0,0], ':'),
357 0 ▶ (map { (($_ > 0 ? (WWW::Shopify::Liquid::Token::Separator->new([0,0,0], ',')) : ()), $self->unparse_argument_tokens($args[$_])) } 0..$#args)
Branch: 1 branch
BranchTrueFalseTotal
$_ > 0 ? : 0 0 0
358 )
359 }) : ())
360 );
361 0 return @optokens;
362 } elsif ($ast->isa('WWW::Shopify::Liquid::Operator')) {
363 0 my @optokens = ($self->unparse_argument_tokens($ast->{operands}->[0]), WWW::Shopify::Liquid::Token::Operator->new([0,0,0], $ast->{core}), $self->unparse_argument_tokens($ast->{operands}->[1]));
364 0 ▶ return WWW::Shopify::Liquid::Token::Grouping->new([0,0,0], @optokens) if $ast->requires_grouping;
Branch: 1 branch
BranchTrueFalseTotal
if $ast->requires_grouping 0 0 0
365 0 return @optokens;
366 } else {
367 0 return $ast;
368 }
369 }
370  
371 sub unparse_tokens {
372 0 ▶ my ($self, $ast) = @_;
Subroutine unparse_tokens: not called CC=12 SCAR=50.5
373 0 ▶ return $ast if $self->is_processed($ast) || $ast->isa('WWW::Shopify::Liquid::Token');
Branch: 1 branch
BranchTrueFalseTotal
if $self->is_processed($ast) or $ast->isa("WWW::Shopify::Liquid::Token") 0 0 0
Condition0%0/3
$self->is_processed($ast) or $ast->isa("WWW::Shopify::Liquid::Token")
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->is_processed($ast) or $ast->isa("WWW::Shopify::Liquid::Token")
$self->is_processed($ast) $ast->isa("WWW::Shopify::Liquid::Token")
Truth table0%0/3
A or B
A= $self->is_processed($ast)B= $ast->isa("WWW::Shopify::Liquid::Token")
ABresult
1X1
011
000
374 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Tag')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ast->isa("WWW::Shopify::Liquid::Tag")) 0 0 0
375 0 ▶ my @arguments = $ast->{arguments} ? $self->unparse_argument_tokens(@{$ast->{arguments}}) : ();
Branch: 1 branch
BranchTrueFalseTotal
$ast->{'arguments'} ? : 0 0 0
376 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Tag::Enclosing')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ast->isa('WWW::Shopify::Liquid::Tag::Enclosing')) { } 0 0 0
elsif ($ast->isa('WWW::Shopify::Liquid::Tag::Output')) { } 0 0 0
377 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Tag::If')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ast->isa('WWW::Shopify::Liquid::Tag::If')) { } 0 0 0
378 0 ▶ return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments), $self->unparse_tokens($ast->{true_path}), WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'end' . $ast->{core})) if !$ast->{false_path};
Branch: 1 branch
BranchTrueFalseTotal
unless $ast->{"false_path"} 0 0 0
379 0 ▶ if ($ast->{false_path}->isa('WWW::Shopify::Liquid::Tag::If')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")) 0 0 0
380 # Untangle the thing, and spread out in an array all if statement that have if statements as their false_paths.
381 0 my @elsifs;
382 my $recursive;
383 $recursive = sub {
384 0 ▶ my ($ast) = @_;
Subroutine __ANON__: not called CC=5 SCAR=34.0
385 0 ▶ push(@elsifs, WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'elsif', ($ast->{arguments} ? [$self->unparse_argument_tokens(@{$ast->{arguments}})] : [])), $self->unparse_tokens($ast->{true_path}));
Branch: 1 branch
BranchTrueFalseTotal
$ast->{'arguments'} ? : 0 0 0
386 0 ▶ if ($ast->{false_path} && $ast->{false_path}->isa('WWW::Shopify::Liquid::Tag::If')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ast->{'false_path'} and $ast->{'false_path'}->isa('WWW::Shopify::Liquid::Tag::If')) { } 0 0 0
elsif ($ast->{'false_path'}) { } 0 0 0
Condition0%0/3
$ast->{"false_path"} and $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
!ll&&!rl&&r
000
MC/DC0%0/2
$ast->{"false_path"} and $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
$ast->{"false_path"} $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
Truth table0%0/3
A and B
A= $ast->{"false_path"}B= $ast->{"false_path"}->isa("WWW::Shopify::Liquid::Tag::If")
ABresult
0X0
100
111
387 0 $recursive->($ast->{false_path});
388 } elsif ($ast->{false_path}) {
389 0 push(@elsifs, WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'else'), $self->unparse_tokens($ast->{false_path}));
390 }
391 0 };
392 0 $recursive->($ast->{false_path});
393 0 return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments), $self->unparse_tokens($ast->{true_path}), @elsifs, WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'end'. $ast->{core}));
394 }
395 0 return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments), $self->unparse_tokens($ast->{true_path}), WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'else'), $self->unparse_tokens($ast->{false_path}), WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'end'. $ast->{core}));
396 }
397 else {
398 0 return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments), $self->unparse_tokens($ast->{contents}), WWW::Shopify::Liquid::Token::Tag->new([0,0,0], 'end' . $ast->{core}));
399 }
400 }
401 elsif ($ast->isa('WWW::Shopify::Liquid::Tag::Output')) {
402 0 return (WWW::Shopify::Liquid::Token::Output->new([0,0,0], [$self->unparse_argument_tokens(@{$ast->{arguments}})]));
403 }
404 else {
405 0 return (WWW::Shopify::Liquid::Token::Tag->new([0,0,0], $ast->{core}, \@arguments));
406 }
407 0 return $ast;
408 }
409 0 ▶ if ($ast->isa('WWW::Shopify::Liquid::Filter')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ast->isa("WWW::Shopify::Liquid::Filter")) 0 0 0
410 0 return $ast;
411 }
412 0 ▶ return (map { $self->unparse_tokens($_) } @{$ast->{operands}}) if ($ast->isa('WWW::Shopify::Liquid::Operator::Concatenate'));
Branch: 1 branch
BranchTrueFalseTotal
if $ast->isa("WWW::Shopify::Liquid::Operator::Concatenate") 0 0 0
413
414 }
415  
416 1;
« blib/lib/WWW/Shopify/Liquid/Tag/Assign.pm ↑ Summary blib/lib/WWW/Shopify/Liquid/Operator/Concatenate.pm »