use strict;
use Test::More;
-plan tests => 2063;
+plan tests => 2071;
use feature (sprintf(":%vd", $^V)); # to avoid relying on the feature
# logic to add CORE::
for my $lex (0, 1, 2) {
if ($lex) {
next if $keyword =~ /local|our|state|my/;
- # XXX glob(my $x) incorrectly becomes <my $x>
- next if $keyword eq 'glob';
}
my $vars = $lex == 1 ? 'my($a, $b, $c, $d, $e);' . "\n " : "";
testit exec => 'CORE::exec($foo $bar);';
-# glob($x) gets deparsed as glob("$x").
-# Whether this is correct, I don't know; but I didn't want
-# to start messing with the whole glob/readline/<> mess - DAPM.
-testit glob => 'glob;', 'glob("$_");';
-testit glob => 'CORE::glob;', 'glob("$_");';
-testit glob => 'glob $a;', 'glob("$a");';
-testit glob => 'CORE::glob $a;', 'glob("$a");';
+testit glob => 'glob;', 'glob($_);';
+testit glob => 'CORE::glob;', 'CORE::glob($_);';
+testit glob => 'glob $a;', 'glob($a);';
+testit glob => 'CORE::glob $a;', 'CORE::glob($a);';
testit grep => 'CORE::grep { $a } $b, $c', 'grep({$a;} $b, $c);';
# keywords that are strong and also have a prototype
#
my %strong_proto_keywords = map { $_ => 1 } qw(
- glob
pos
prototype
scalar
sub pp_glob {
my $self = shift;
my($op, $cx) = @_;
- my $text = $self->dq($op->first->sibling); # skip pushmark
+ my $kid = $op->first->sibling; # skip pushmark
my $keyword =
$op->flags & OPf_SPECIAL ? 'glob' : $self->keyword('glob');
- if ($text =~ /^\$?(\w|::|\`)+$/ # could look like a readline
- or $keyword =~ /^CORE::/
+ my $text;
+ if ($keyword =~ /^CORE::/
+ or $kid->name ne 'const'
+ or ($text = $self->dq($kid))
+ =~ /^\$?(\w|::|\`)+$/ # could look like a readline
or $text =~ /[<>]/) {
- return "$keyword(" . single_delim('qq', '"', $text) . ')';
+ $text = $self->deparse($kid);
+ return $cx >= 5 || $self->{'parens'}
+ ? "$keyword($text)"
+ : "$keyword $text";
} else {
return '<' . $text . '>';
}