This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
better handle freeing of code blocks in /(?{...})/
[perl5.git] / t / op / concat2.t
CommitLineData
1222f39e
FC
1#!./perl
2
3# This file is for concatenation tests that require test.pl.
4#
3a069a00
FC
5# t/opbasic/concat.t cannot use test.pl as
6# it needs to avoid using concatenation in
1222f39e
FC
7# its ok() function.
8
9BEGIN {
10 chdir 't' if -d 't';
1222f39e 11 require './test.pl';
624c42e2 12 set_up_inc('../lib');
1222f39e
FC
13}
14
c3124964 15plan 2;
583a5589
FC
16
17# This test is in the file because overload.pm uses concatenation.
18{ package o; use overload '""' => sub { $_[0][0] } }
19$x = bless[chr 256],o::;
20"$x";
21$x->[0] = "\xff";
22$x.= chr 257;
23$x.= chr 257;
24is $x, "\xff\x{101}\x{101}", '.= is not confused by changing utf8ness';
f5a0fd1e
FC
25
26# Ops should not share the same TARG between recursion levels. This may
27# affect other ops, too, but concat seems more susceptible to this than
28# others, since it can call itself recursively. (Where else would I put
29# this test, anyway?)
30fresh_perl_is <<'end', "tmp\ntmp\n", {},
31 sub canonpath {
32 my ($path) = @_;
33 my $node = '';
34 $path =~ s|/\z||;
35 return "$node$path";
36 }
37
38 {
39 package Path::Class::Dir;
40 use overload q[""] => sub { ::canonpath("tmp") };
41 }
42
43 print canonpath("tmp"), "\n";
44 print canonpath(bless {},"Path::Class::Dir"), "\n";
45end
46 "recursive concat does not share TARGs";