From 450254c9d54a1fa9d3105b5d9d06b5ec98519a2d Mon Sep 17 00:00:00 2001 From: Tom Wyant Date: Tue, 3 Oct 2023 21:43:52 -0400 Subject: [PATCH] Localize $Test::Builder::Level before modification. --- inc/My/Module/Test.pm | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/inc/My/Module/Test.pm b/inc/My/Module/Test.pm index ba652aee..8b1cd13a 100644 --- a/inc/My/Module/Test.pm +++ b/inc/My/Module/Test.pm @@ -92,7 +92,7 @@ sub cache_count { $result = PPIx::Regexp->__cache_size(); # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; return is( $result, $expect, "Should be $expect leftover cache contents" ); } @@ -108,7 +108,7 @@ sub klass { $result = ref $obj || $obj; # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; if ( defined $class ) { my $rslt = isa_ok( $obj, $class ) or diag " Instead, $kind $nav isa $result"; @@ -129,7 +129,7 @@ sub count { my $expect = pop @args; # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; if ( ARRAY_REF eq ref $parse ) { $result = @{ $parse }; return is( $result, $expect, "Expect $expect tokens" ); @@ -151,7 +151,7 @@ sub different { my ( $left, $right, $name ) = @args; # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; if ( ! defined $left && ! defined $right ) { return ok( undef, $name ); } elsif ( ! defined $left || ! defined $right ) { @@ -174,7 +174,7 @@ sub dump_result { my $got = PPIx::Regexp::Dumper->new( $obj, @args )->string(); # cperl does not seem to like goto &xxx; it throws a deep # recursion error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; return is( $got, $expect, $name ); } elsif ( __instance( $result, 'PPIx::Regexp::Tokenizer' ) || __instance( $result, 'PPIx::Regexp::Element' ) ) { @@ -195,7 +195,7 @@ sub equals { my ( $left, $right, $name ) = @args; # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; if ( ! defined $left && ! defined $right ) { return ok( 1, $name ); } elsif ( ! defined $left || ! defined $right ) { @@ -223,7 +223,7 @@ sub false { my $class = ref $obj; # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; if ( $obj->can( $method ) ) { $result = $obj->$method( @{ $args } ); my $fmtd = _format_args( $args ); @@ -240,7 +240,7 @@ sub finis { $result = PPIx::Regexp::Element->__parent_keys(); # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; return is( $result, 0, 'Should be no leftover objects' ); } @@ -308,7 +308,7 @@ sub parse { ## no critic (RequireArgUnpacking) $opt->{test} or return; # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; return isa_ok( $parse, 'PPIx::Regexp' ); } @@ -325,7 +325,7 @@ sub ppi { ## no critic (RequireArgUnpacking) } # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; return is( $result, $expect, "$kind $nav ppi() content '$safe'" ); } @@ -333,7 +333,7 @@ sub raw_width { my ( $min, $max, $name ) = @_; defined $name or $name = sprintf q<%s '%s'>, ref $obj, $obj->content(); - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; my @width = $obj->raw_width(); return is( $width[0], $min, "$name raw minimum witdh" ) && is( $width[1], $max, "$name raw maximum width" ); @@ -363,7 +363,7 @@ sub tokenize { ## no critic (RequireArgUnpacking) $result = $parse; $nav = ''; $opt->{test} or return; - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; return isa_ok( $obj, 'PPIx::Regexp::Tokenizer' ); } @@ -374,7 +374,7 @@ sub true { ## no critic (RequireArgUnpacking) my $class = ref $obj; # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; if ( $obj->can( $method ) ) { $result = $obj->$method( @{ $args } ); my $fmtd = _format_args( $args ); @@ -394,7 +394,7 @@ sub value { ## no critic (RequireArgUnpacking) my $class = ref $obj || $obj || $initial_class; # cperl does not seem to like goto &xxx; it throws a deep recursion # error if you do it enough times. - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; if ( ! $invocant->can( $method ) ) { return ok( undef, "$class->$method() exists" ); } @@ -418,7 +418,7 @@ sub width { my ( $min, $max, $name ) = @_; defined $name or $name = sprintf q<%s '%s'>, ref $obj, $obj->content(); - $Test::Builder::Level = $Test::Builder::Level + 1; + local $Test::Builder::Level = $Test::Builder::Level + 1; my @width = $obj->width(); return is( $width[0], $min, "$name minimum witdh" ) && is( $width[1], $max, "$name maximum width" );