This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Get t/uni/cache.t working under minitest
[perl5.git] / t / op / concat2.t
CommitLineData
1222f39e
FC
1#!./perl
2
3# This file is for concatenation tests that require test.pl.
4#
5# concat.t cannot use test.pl as it needs to avoid using concatenation in
6# its ok() function.
7
8BEGIN {
9 chdir 't' if -d 't';
10 @INC = '../lib';
11 require './test.pl';
12}
13
f5a0fd1e 14plan 3;
1222f39e 15
4a608acc
FC
16SKIP: {
17skip_if_miniperl("no dynamic loading on miniperl, no Encode", 1);
1222f39e 18fresh_perl_is <<'end', "ok\n", {},
ce6a2be4 19 no warnings 'deprecated';
1222f39e
FC
20 use encoding 'utf8';
21 map { "a" . $a } ((1)x5000);
22 print "ok\n";
23end
24 "concat does not lose its stack pointer after utf8 upgrade [perl #78674]";
4a608acc 25}
583a5589
FC
26
27# This test is in the file because overload.pm uses concatenation.
28{ package o; use overload '""' => sub { $_[0][0] } }
29$x = bless[chr 256],o::;
30"$x";
31$x->[0] = "\xff";
32$x.= chr 257;
33$x.= chr 257;
34is $x, "\xff\x{101}\x{101}", '.= is not confused by changing utf8ness';
f5a0fd1e
FC
35
36# Ops should not share the same TARG between recursion levels. This may
37# affect other ops, too, but concat seems more susceptible to this than
38# others, since it can call itself recursively. (Where else would I put
39# this test, anyway?)
40fresh_perl_is <<'end', "tmp\ntmp\n", {},
41 sub canonpath {
42 my ($path) = @_;
43 my $node = '';
44 $path =~ s|/\z||;
45 return "$node$path";
46 }
47
48 {
49 package Path::Class::Dir;
50 use overload q[""] => sub { ::canonpath("tmp") };
51 }
52
53 print canonpath("tmp"), "\n";
54 print canonpath(bless {},"Path::Class::Dir"), "\n";
55end
56 "recursive concat does not share TARGs";