Skip to content

Commit

Permalink
Use strict and warnings in B::Deparse tests
Browse files Browse the repository at this point in the history
This would have caught the duplicate (and it turns out, useless)
definition of $expr in do_infix_keyword().
  • Loading branch information
ilmari committed Jul 20, 2023
1 parent 4867818 commit 87b6714
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/B/Deparse-core.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ BEGIN {
}
}

use warnings;
use strict;
use Test::More;

Expand Down Expand Up @@ -83,8 +84,7 @@ sub testit {
package lexsubtest;
no warnings 'experimental::lexical_subs';
use feature 'lexical_subs';
no strict 'vars';
$code = "sub { state sub $keyword; ${vars}() = $expr }";
$code = "no warnings 'syntax'; no strict 'vars'; sub { state sub $keyword; ${vars}() = $expr }";
$code = "use feature 'isa';\n$code" if $keyword eq "isa";
$code = "use feature 'switch';\n$code" if $keyword eq "break";
$code_ref = eval $code or die "$@ in $expr";
Expand All @@ -93,7 +93,7 @@ sub testit {
package test;
use subs ();
import subs $keyword;
$code = "no strict 'vars'; sub { ${vars}() = $expr }";
$code = "no warnings 'syntax'; no strict 'vars'; sub { ${vars}() = $expr }";
$code = "use feature 'isa';\n$code" if $keyword eq "isa";
$code = "use feature 'switch';\n$code" if $keyword eq "break";
$code_ref = eval $code or die "$@ in $expr";
Expand Down Expand Up @@ -132,9 +132,7 @@ my %infix_map = qw(and && or ||);
sub do_infix_keyword {
my ($keyword, $parens, $strong) = @_;
$SEEN_STRENGTH{$keyword} = $strong;
my $expr = "(\$a $keyword \$b)";
my $nkey = $infix_map{$keyword} // $keyword;
my $expr = "(\$a $keyword \$b)";
my $exp = "\$a $nkey \$b";
$exp = "($exp)" if $parens;
$exp .= ";";
Expand Down
4 changes: 3 additions & 1 deletion lib/B/Deparse-subclass.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
# publicise an API for subclassing B::Deparse they can prevent us from
# gratuitously breaking conventions that CPAN modules already use.

use warnings;
use strict;
use Test::More;

use B::Deparse;

package B::Deparse::NameMangler {
@ISA = "B::Deparse";
our @ISA = "B::Deparse";
sub padname { SUPER::padname{@_} . '_groovy' }
}

Expand Down

0 comments on commit 87b6714

Please sign in to comment.