Skip to content

Commit 053330e

Browse files
Copilotoalders
andcommitted
Add comprehensive test cases for quote-like strings
Co-authored-by: oalders <[email protected]>
1 parent edd51aa commit 053330e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

t/double-quoted-q.t

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,20 @@ ok( defined $tidied2, 'tidied_document returns a result for pack("qq")' );
4444
# Make sure the tidied document still contains the pack statement
4545
like( $tidied2, qr/pack\("qq"/, 'pack statement is preserved' );
4646

47+
# Test various quote-like strings
48+
my ( $doc3, $logs3 ) = doc(
49+
filename => 'test-data/various-quote-strings.pl',
50+
);
51+
52+
my $tidied3 = $doc3->tidied_document;
53+
54+
ok(
55+
do {
56+
none { $_->{level} eq 'error' } @$logs3;
57+
},
58+
'no errors in logs for various quote-like strings'
59+
);
60+
61+
ok( defined $tidied3, 'tidied_document returns a result for various quote-like strings' );
62+
4763
done_testing;

test-data/various-quote-strings.pl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use strict;
2+
use warnings;
3+
4+
# Test various quote-like strings that should not cause errors
5+
use List::Util;
6+
7+
# Simple cases from the issue
8+
my $str1 = "q";
9+
my $str2 = "qq";
10+
11+
# Other quote operators
12+
my $str3 = "qw";
13+
my $str4 = "qx";
14+
my $str5 = "qr";
15+
16+
# Regex operators
17+
my $str6 = "m";
18+
my $str7 = "s";
19+
my $str8 = "tr";
20+
my $str9 = "y";
21+
22+
# Combinations
23+
my $str10 = "q and qq";
24+
my $str11 = pack("qq", 10, 0);
25+
26+
# Words that start with these letters but aren't operators
27+
my $str12 = "quest";
28+
my $str13 = "query";
29+
my $str14 = "queue";

0 commit comments

Comments
 (0)