Skip to content

Commit 6a3cf23

Browse files
committed
join: add tests from my comments on #21484
1 parent 828ea27 commit 6a3cf23

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

t/op/join.t

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN {
66
set_up_inc('../lib');
77
}
88

9-
plan tests => 41;
9+
plan tests => 43;
1010

1111
@x = (1, 2, 3);
1212
is( join(':',@x), '1:2:3', 'join an array with character');
@@ -179,3 +179,37 @@ isnt $_[1], $_[0],
179179
}
180180
is( $SM::fetched, 3, 'FETCH called 1 + 2 times' );
181181
}
182+
{
183+
# see GH #21484
184+
local $TODO = "changes to delim have an effect";
185+
my $expect = "a\x{100}x\x{100}b\n";
186+
utf8::encode($expect);
187+
fresh_perl_is(<<'CODE', $expect, {}, "modifications delim from magic should be ignored");
188+
my $n = 1;
189+
my $sep = "\x{100}" x $n;
190+
package MyOver {
191+
use overload '""' => sub { $sep = "\xFF" x $n; "x" };
192+
}
193+
194+
my $x = bless {}, "MyOver";
195+
binmode STDOUT, ":utf8";
196+
print join($sep, "a", $x, "b"), "\n";
197+
CODE
198+
}
199+
{
200+
# see GH #21484
201+
my $expect = "x\x{100}a\n";
202+
local $TODO = "modifications to delim PVX caused UB";
203+
utf8::encode($expect); # fresh_perl() does bytes
204+
fresh_perl_is(<<'CODE', $expect, {}, "modifications to delim PVX shouldn't crash");
205+
my $n = 1;
206+
my $sep = "\x{100}" x $n;
207+
package MyOver {
208+
use overload '""' => sub { $sep = "\xFF" x ($n+20); "x" };
209+
}
210+
211+
my $x = bless {}, "MyOver";
212+
binmode STDOUT, ":utf8";
213+
print join($sep, $x, "a"), "\n";
214+
CODE
215+
}

0 commit comments

Comments
 (0)