11 # Think carefully before adding tests here. In general this should be
12 # used only for about three categories of tests:
14 # (1) tests that absolutely require 'use utf8', and since that in general
15 # shouldn't be needed as the utf8 is being obsoleted, this should
16 # have rather few tests. If you want to test Unicode and regexes,
17 # you probably want to go to op/regexp or op/pat; if you want to test
18 # split, go to op/split; pack, op/pack; appending or joining,
19 # op/append or op/join, and so forth
21 # (2) tests that have to do with Unicode tokenizing (though it's likely
22 # that all the other Unicode tests sprinkled around the t/**/*.t are
23 # going to catch that)
25 # (3) complicated tests that simultaneously stress so many Unicode features
26 # that deciding into which other test script the tests should go to
27 # is hard -- maybe consider breaking up the complicated test
38 { use bytes; $a = "\xc3\xa4" }
39 { use utf8; $b = "\xe4" }
45 { use utf8; ok($a ne $b) }
52 my $smiley = "\x{263a}";
54 for my $s ("\x{263a}",
63 my $length_chars = length($s);
65 { use bytes; $length_bytes = length($s) }
66 my @regex_chars = $s =~ m/(.)/g;
67 my $regex_chars = @regex_chars;
68 my @split_chars = split //, $s;
69 my $split_chars = @split_chars;
70 ok("$length_chars/$regex_chars/$split_chars/$length_bytes" eq
74 for my $s ("\x{263a}" . "\x{263a}",
83 my $length_chars = length($s);
85 { use bytes; $length_bytes = length($s) }
86 my @regex_chars = $s =~ m/(.)/g;
87 my $regex_chars = @regex_chars;
88 my @split_chars = split //, $s;
89 my $split_chars = @split_chars;
90 ok("$length_chars/$regex_chars/$split_chars/$length_bytes" eq
98 local $SIG{__WARN__} = sub { print "#($_[0])\n"; $w++ };
99 my $x = eval q/"\\/ . "\x{100}" . q/"/;;
101 ok($w == 0 && $x eq "\x{100}");
105 my $progfile = 'utf' . $$;
106 END {unlink $progfile}
107 open P, ">$progfile" or die "Can't open '$progfile': $!";
108 # Interpolation of hex characters needs to take place now, as we're
109 # testing feeding malformed utf8 into perl. Bug now fixed was an
110 # "out of memory" error. We really need the "" [rather than qq() or q()]
111 # to get the best explosion.
113 use utf8; %a = ("\xE1\xA0"=>"sterling");
114 print 'start'; printf '%x,', ord $_ foreach keys %a; print "end\n";
116 print "# Possible delay...\n";
117 my $result = runperl ( verbose => 1, stderr => 1, progfile => $progfile );
119 qr/^Malformed UTF-8 character \(2 bytes, need 3\).*start\d+,end$/s);