]> git.donarmstrong.com Git - perltidy.git/commitdiff
add support for new ^^ logical xor, see git #154
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 23 Jul 2024 14:02:10 +0000 (07:02 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 23 Jul 2024 14:02:10 +0000 (07:02 -0700)
CHANGES.md
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/Tokenizer.pm
t/snippets/expect/logical_xor.def [new file with mode: 0644]
t/snippets/logical_xor.in [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets30.t

index 62289053083e621e5e97f30bf3c7da487537362c..f95f9149cf50240119951784da6d5b7521a8aaf7 100644 (file)
@@ -2,6 +2,13 @@
 
 ## 2024 05 11.06
 
+    - Add logical xor operator ^^ available in perl version 5.40, as
+      noted in git #157.
+
+    - Keyword 'state' now has default space before a paren, like 'my'.
+      Previously there was no space and no control.  So the default
+      is now "state ($x)". This space can be removed with -nsak='state'.
+
     - Add options --add-lone-trailing-commas, -altc and
       --delete-lone-trailing-commas, -dltc, to add control over adding
       and deleting the only comma in a list.  See discussion in git #143
index 7fa1ae689dc033b35fa5099dc6352ec1e2ebdb6d..4e9af373f048435a40edfc319923e5c8741a8646 100644 (file)
@@ -3072,7 +3072,7 @@ sub initialize_whitespace_hashes {
     my @spaces_both_sides = qw#
       + - * / % ? = . : x < > | & ^ .. << >> ** && .. || // => += -=
       .= %= x= &= |= ^= *= <> <= >= == =~ !~ /= != ... <<= >>= ~~ !~~
-      **= &&= ||= //= <=> A k f w F n C Y U G v P S
+      **= &&= ||= //= <=> A k f w F n C Y U G v P S ^^
       #;
 
     my @spaces_left_side = qw<
@@ -4019,7 +4019,7 @@ EOM
 
         @q = qw(
           .. :: << >> ** && || // -> => += -= .= %= &= |= ^= *= <>
-          <= >= == =~ !~ != ++ -- /= x= ~~ ~. |. &. ^.
+          <= >= == =~ !~ != ++ -- /= x= ~~ ~. |. &. ^. ^^
         );
         @is_digraph{@q} = (1) x scalar(@q);
 
index 20de7f847cf157df4c4120268e0eda708235acb5..bdacb4640e090a4cf19a8d25b446d9c672bd803a 100644 (file)
@@ -10727,7 +10727,7 @@ For the following tokens, the "type" of a token is just the token itself.
 .. :: << >> ** && .. || // -> => += -= .= %= &= |= ^= *= <>
 ( ) <= >= == =~ !~ != ++ -- /= x=
 ... **= <<= >>= &&= ||= //= <=>
-, + - / * | % ! x ~ = \ ? : . < > ^ &
+, + - / * | % ! x ~ = \ ? : . < > ^ & ^^
 
 The following additional token types are defined:
 
@@ -10890,7 +10890,7 @@ BEGIN {
 
     my @digraphs = qw(
       .. :: << >> ** && || // -> => += -= .= %= &= |= ^= *= <>
-      <= >= == =~ !~ != ++ -- /= x= ~~ ~. |. &. ^.
+      <= >= == =~ !~ != ++ -- /= x= ~~ ~. |. &. ^. ^^
     );
     @is_digraph{@digraphs} = (1) x scalar(@digraphs);
 
@@ -11270,7 +11270,7 @@ BEGIN {
       **= += -= .= /= *= %= x= &= |= ^= <<= >>= &&= ||= //=
       <= >= == != => \ > < % * / ? & | ** <=> ~~ !~~ <<~
       f F pp mm Y p m U J G j >> << ^ t
-      ~. ^. |. &. ^.= |.= &.=
+      ~. ^. |. &. ^.= |.= &.= ^^
       #;
     push( @value_requestor_type, ',' )
       ;    # (perl doesn't like a ',' in a qw block)
diff --git a/t/snippets/expect/logical_xor.def b/t/snippets/expect/logical_xor.def
new file mode 100644 (file)
index 0000000..8670e81
--- /dev/null
@@ -0,0 +1 @@
+$x ^^ $y and say "One of x or y is true, but not both";
diff --git a/t/snippets/logical_xor.in b/t/snippets/logical_xor.in
new file mode 100644 (file)
index 0000000..49b3225
--- /dev/null
@@ -0,0 +1 @@
+$x^^$y and say "One of x or y is true, but not both";
index 97d86f4ce1619b0d345d5c349e28c7dbfa9ab24b..042f2c81d6b5a9eeedea494adc11354391e743c3 100644 (file)
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
+../snippets30.t        logical_xor.def
index 35455a9c2be94745f43558116da5f82f43aaaddf..1008631c034769e3b4e7a859234c5d8404251ba0 100644 (file)
@@ -11,6 +11,7 @@
 #8 dltc.def
 #9 dltc.dltc1
 #10 dltc.dltc2
+#11 logical_xor.def
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -84,6 +85,10 @@ $self->make_grammar(
                     [ [ 1950, 150, ], [ 2050, 150, ], ],
                 ]
             );
+----------
+
+        'logical_xor' => <<'----------',
+$x^^$y and say "One of x or y is true, but not both";
 ----------
     };
 
@@ -229,6 +234,14 @@ $self->make_grammar(
 );
 #10...........
         },
+
+        'logical_xor.def' => {
+            source => "logical_xor",
+            params => "def",
+            expect => <<'#11...........',
+$x ^^ $y and say "One of x or y is true, but not both";
+#11...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};