xref: /openbsd/gnu/usr.bin/perl/t/uni/lex_utf8.t (revision 898184e3)
1#!./perl -w
2#
3# This script is written intentionally in UTF-8
4
5BEGIN {
6    $| = 1;
7
8    require './test.pl';
9    skip_all_if_miniperl("no dynamic loading on miniperl, no re");
10    skip_all('EBCDIC') if $::IS_EBCDIC;
11}
12
13use strict;
14
15plan (tests => 11);
16use charnames ':full';
17
18use utf8;
19
20my $A_with_ogonek = "Ą";
21my $micro_sign = "µ";
22my $hex_first = "a\x{A2}Ą";
23my $hex_last = "aĄ\x{A2}";
24my $name_first = "b\N{MICRO SIGN}Ɓ";
25my $name_last = "bƁ\N{MICRO SIGN}";
26my $uname_first = "b\N{U+00B5}Ɓ";
27my $uname_last = "bƁ\N{U+00B5}";
28my $octal_first = "c\377Ć";
29my $octal_last = "cĆ\377";
30
31do {
32	use bytes;
33	is((join "", unpack("C*", $A_with_ogonek)), "196" . "132", 'single char above 0x100');
34	is((join "", unpack("C*", $micro_sign)), "194" . "181", 'single char in 0x80 .. 0xFF');
35	is((join "", unpack("C*", $hex_first)), "97" . "194" . "162" . "196" . "132", 'a . \x{A2} . char above 0x100');
36	is((join "", unpack("C*", $hex_last)), "97" . "196" . "132" . "194" . "162", 'a . char above 0x100 . \x{A2}');
37	is((join "", unpack("C*", $name_first)), "98" . "194" . "181" . "198" . "129", 'b . \N{MICRO SIGN} . char above 0x100');
38	is((join "", unpack("C*", $name_last)), "98" . "198" . "129" . "194" . "181", 'b . char above 0x100 . \N{MICRO SIGN}');
39	is((join "", unpack("C*", $uname_first)), "98" . "194" . "181" . "198" . "129", 'b . \N{U+00B5} . char above 0x100');
40	is((join "", unpack("C*", $uname_last)), "98" . "198" . "129" . "194" . "181", 'b . char above 0x100 . \N{U+00B5}');
41	is((join "", unpack("C*", $octal_first)), "99" . "195" . "191" . "196" . "134", 'c . \377 . char above 0x100');
42	is((join "", unpack("C*", $octal_last)), "99" . "196" . "134" . "195" . "191", 'c . char above 0x100 . \377');
43};
44
45{
46    local $SIG{__WARN__} = sub {};
47    eval "our $::\xe9; $\xe9";
48    unlike $@, qr/utf8_heavy/,
49	'No utf8_heavy errors with our() syntax errors';
50}
51__END__
52
53