diff --git a/t/lib/NGCP/Test/Patch.pm b/t/lib/NGCP/Test/Patch.pm index d5be1d1200..74388205e5 100644 --- a/t/lib/NGCP/Test/Patch.pm +++ b/t/lib/NGCP/Test/Patch.pm @@ -15,8 +15,8 @@ sub apply_patch { for my $op (@{ $patch }) { my $coderef = JSON::Pointer->can($op->{op}); die "invalid op '".$op->{op}."' despite schema validation" unless $coderef; - for ($op->{op}) { - if ('add' eq $_ or 'replace' eq $_) { + for my $op_name ($op->{op}) { + if ('add' eq $op_name or 'replace' eq $op_name) { try { $entity = $coderef->('JSON::Pointer', $entity, $op->{path}, $op->{value}); } catch($pe) { @@ -29,7 +29,7 @@ sub apply_patch { die($pe); #->rethrow; } } - } elsif ('remove' eq $_) { + } elsif ('remove' eq $op_name) { try { $entity = $coderef->('JSON::Pointer', $entity, $op->{path}); } catch($pe) { @@ -42,7 +42,7 @@ sub apply_patch { die($pe); #->rethrow; } } - } elsif ('move' eq $_ or 'copy' eq $_) { + } elsif ('move' eq $op_name or 'copy' eq $op_name) { try { $entity = $coderef->('JSON::Pointer', $entity, $op->{from}, $op->{path}); } catch($pe) { @@ -55,7 +55,7 @@ sub apply_patch { die($pe); #->rethrow; } } - } elsif ('test' eq $_) { + } elsif ('test' eq $op_name) { try { die "test failed - path: $op->{path} value: $op->{value}\n" unless $coderef->('JSON::Pointer', $entity, $op->{path}, $op->{value}); diff --git a/t/lib/Test/ApplyPatch.pm b/t/lib/Test/ApplyPatch.pm index f7fac21ef4..62af8cdee3 100644 --- a/t/lib/Test/ApplyPatch.pm +++ b/t/lib/Test/ApplyPatch.pm @@ -22,8 +22,8 @@ sub apply_patch { for my $op (@{ $patch }) { my $coderef = JSON::Pointer->can($op->{op}); die "invalid op '".$op->{op}."' despite schema validation" unless $coderef; - for ($op->{op}) { - if ('add' eq $_ or 'replace' eq $_) { + for my $op_name ($op->{op}) { + if ('add' eq $op_name or 'replace' eq $op_name) { try { $entity = $coderef->('JSON::Pointer', $entity, $op->{path}, $op->{value}); } catch($pe) { @@ -36,7 +36,7 @@ sub apply_patch { die($pe); #->rethrow; } } - } elsif ('remove' eq $_) { + } elsif ('remove' eq $op_name) { try { $entity = $coderef->('JSON::Pointer', $entity, $op->{path}); } catch($pe) { @@ -49,7 +49,7 @@ sub apply_patch { die($pe); #->rethrow; } } - } elsif ('move' eq $_ or 'copy' eq $_) { + } elsif ('move' eq $op_name or 'copy' eq $op_name) { try { $entity = $coderef->('JSON::Pointer', $entity, $op->{from}, $op->{path}); } catch($pe) { @@ -62,7 +62,7 @@ sub apply_patch { die($pe); #->rethrow; } } - } elsif ('test' eq $_) { + } elsif ('test' eq $op_name) { try { die "test failed - path: $op->{path} value: $op->{value}\n" unless $coderef->('JSON::Pointer', $entity, $op->{path}, $op->{value}); @@ -82,4 +82,4 @@ sub apply_patch { } return $entity; } -1; \ No newline at end of file +1;