Re: unicode support and perl [ID 20000901.097]
[p5sagit/p5-mst-13.2.git] / t / op / append.t
1 #!./perl
2
3 # $RCSfile: append.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:36 $
4
5 print "1..14\n";
6
7 $a = 'ab' . 'c';        # compile time
8 $b = 'def';
9
10 $c = $a . $b;
11 print "#1\t:$c: eq :abcdef:\n";
12 if ($c eq 'abcdef') {print "ok 1\n";} else {print "not ok 1\n";}
13
14 $c .= 'xyz';
15 print "#2\t:$c: eq :abcdefxyz:\n";
16 if ($c eq 'abcdefxyz') {print "ok 2\n";} else {print "not ok 2\n";}
17
18 $_ = $a;
19 $_ .= $b;
20 print "#3\t:$_: eq :abcdef:\n";
21 if ($_ eq 'abcdef') {print "ok 3\n";} else {print "not ok 3\n";}
22
23 # test that when right argument of concat is UTF8, and is the same
24 # variable as the target, and the left argument is not UTF8, it no
25 # longer frees the wrong string.
26 {
27     sub r2 {
28         my $string = '';
29         $string .= pack("U0a*", 'mnopqrstuvwx');
30         $string = "abcdefghijkl$string";
31     }
32
33     r2() and print "ok $_\n" for qw/ 4 5 /;
34 }
35
36 # test that nul bytes get copied
37 {
38     my($a, $ab) = ("a", "a\000b");
39     my($u, $ub) = map pack("U0a*", $_), $a, $ab;
40     my $t1 = $a; $t1 .= $ab;
41     print $t1 =~ /b/ ? "ok 6\n" : "not ok 6\t# $t1\n";
42     my $t2 = $a; $t2 .= $ub;
43     print $t2 =~ /b/ ? "ok 7\n" : "not ok 7\t# $t2\n";
44     my $t3 = $u; $t3 .= $ab;
45     print $t3 =~ /b/ ? "ok 8\n" : "not ok 8\t# $t3\n";
46     my $t4 = $u; $t4 .= $ub;
47     print $t4 =~ /b/ ? "ok 9\n" : "not ok 9\t# $t4\n";
48     my $t5 = $a; $t5 = $ab . $t5;
49     print $t5 =~ /b/ ? "ok 10\n" : "not ok 10\t# $t5\n";
50     my $t6 = $a; $t6 = $ub . $t6;
51     print $t6 =~ /b/ ? "ok 11\n" : "not ok 11\t# $t6\n";
52     my $t7 = $u; $t7 = $ab . $t7;
53     print $t7 =~ /b/ ? "ok 12\n" : "not ok 12\t# $t7\n";
54     my $t8 = $u; $t8 = $ub . $t8;
55     print $t8 =~ /b/ ? "ok 13\n" : "not ok 13\t# $t8\n";
56 }
57
58 # test that undef left and right of utf8 results in a valid string
59 {
60     my $a;
61     $a .= "\x{1ff}";
62     print $a eq "\x{1ff}" ? "ok 14\n" :
63         "not ok 14\t# (undef.0x1ff) ne (0x1ff)\n";
64 }