From 1b7df07e19b9d509f64e617904dbdbd264066b13 Mon Sep 17 00:00:00 2001 From: "Philippe Bruhat (BooK)" Date: Thu, 26 Feb 2026 08:10:23 +0100 Subject: [PATCH] add support for the dotted bitwise operators These operators exist since Perl 5.22. Fixes GH #322 --- lib/PPI/Singletons.pm | 2 ++ t/08_regression.t | 2 +- t/25_increment.t | 2 +- t/data/08_regression/51_bitwise_dotted_ops.code | 1 + t/data/08_regression/51_bitwise_dotted_ops.dump | 6 ++++++ t/data/08_regression/51b_bitwise_dotted_ops.code | 1 + t/data/08_regression/51b_bitwise_dotted_ops.dump | 6 ++++++ t/ppi_token_operator.t | 2 +- 8 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 t/data/08_regression/51_bitwise_dotted_ops.code create mode 100644 t/data/08_regression/51_bitwise_dotted_ops.dump create mode 100644 t/data/08_regression/51b_bitwise_dotted_ops.code create mode 100644 t/data/08_regression/51b_bitwise_dotted_ops.dump diff --git a/lib/PPI/Singletons.pm b/lib/PPI/Singletons.pm index 8d9d7751..fe284167 100644 --- a/lib/PPI/Singletons.pm +++ b/lib/PPI/Singletons.pm @@ -21,8 +21,10 @@ our %OPERATOR = map { $_ => 1 } ( < > <= >= lt gt le ge == != <=> eq ne cmp ~~ & | ^ && || // .. ... + &. |. ^. ~. ? : = **= += -= .= *= /= %= x= &= |= ^= <<= >>= &&= ||= //= + &.= |.= ^.= ~.= => <> <<>> and or xor not }, ',' # Avoids "comma in qw{}" warning diff --git a/t/08_regression.t b/t/08_regression.t index b6026afd..90e998d0 100644 --- a/t/08_regression.t +++ b/t/08_regression.t @@ -7,7 +7,7 @@ use if !(-e 'META.yml'), "Test::InDistDir"; use lib 't/lib'; use PPI::Test::pragmas; -use Test::More tests => 1085 + ($ENV{AUTHOR_TESTING} ? 1 : 0); +use Test::More tests => 1121 + ($ENV{AUTHOR_TESTING} ? 1 : 0); use PPI (); use PPI::Test qw( pause ); diff --git a/t/25_increment.t b/t/25_increment.t index 8942ff6a..7a484077 100644 --- a/t/25_increment.t +++ b/t/25_increment.t @@ -7,7 +7,7 @@ use lib 't/lib'; use PPI::Test::pragmas; -use Test::More tests => 9554 + ($ENV{AUTHOR_TESTING} ? 1 : 0); +use Test::More tests => 9614 + ($ENV{AUTHOR_TESTING} ? 1 : 0); use PPI::Test::Run (); diff --git a/t/data/08_regression/51_bitwise_dotted_ops.code b/t/data/08_regression/51_bitwise_dotted_ops.code new file mode 100644 index 00000000..a83890e2 --- /dev/null +++ b/t/data/08_regression/51_bitwise_dotted_ops.code @@ -0,0 +1 @@ +$x|.$y diff --git a/t/data/08_regression/51_bitwise_dotted_ops.dump b/t/data/08_regression/51_bitwise_dotted_ops.dump new file mode 100644 index 00000000..941e19f4 --- /dev/null +++ b/t/data/08_regression/51_bitwise_dotted_ops.dump @@ -0,0 +1,6 @@ +PPI::Document + PPI::Statement + PPI::Token::Symbol '$x' + PPI::Token::Operator '|.' + PPI::Token::Symbol '$y' + PPI::Token::Whitespace '\n' diff --git a/t/data/08_regression/51b_bitwise_dotted_ops.code b/t/data/08_regression/51b_bitwise_dotted_ops.code new file mode 100644 index 00000000..a0b46398 --- /dev/null +++ b/t/data/08_regression/51b_bitwise_dotted_ops.code @@ -0,0 +1 @@ +$x|.=$y diff --git a/t/data/08_regression/51b_bitwise_dotted_ops.dump b/t/data/08_regression/51b_bitwise_dotted_ops.dump new file mode 100644 index 00000000..a5f6a097 --- /dev/null +++ b/t/data/08_regression/51b_bitwise_dotted_ops.dump @@ -0,0 +1,6 @@ +PPI::Document + PPI::Statement + PPI::Token::Symbol '$x' + PPI::Token::Operator '|.=' + PPI::Token::Symbol '$y' + PPI::Token::Whitespace '\n' diff --git a/t/ppi_token_operator.t b/t/ppi_token_operator.t index fc0ed4eb..45839322 100644 --- a/t/ppi_token_operator.t +++ b/t/ppi_token_operator.t @@ -4,7 +4,7 @@ use lib 't/lib'; use PPI::Test::pragmas; -use Test::More tests => 3009 + ($ENV{AUTHOR_TESTING} ? 1 : 0); +use Test::More tests => 3073 + ($ENV{AUTHOR_TESTING} ? 1 : 0); use PPI (); use PPI::Singletons qw( %KEYWORDS %OPERATOR );