From e7fd7fbb9838833e21605441e36e01a3ccc52e92 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 16 Jun 2020 18:51:26 +0200 Subject: [PATCH] TT#83651 Do not use the topic variable for nested loops This makes the inner loops harder to read. Change-Id: I692f3906bbf110b8f60b5e348dc699716dd979c0 --- t/lib/NGCP/Test/Patch.pm | 10 +++++----- t/lib/Test/ApplyPatch.pm | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) 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;