This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
ignore yet another known scalar leak
[perl5.git] / t / pragma / utf8.t
1 #!./perl 
2
3 BEGIN {
4     chdir 't' if -d 't';
5     unshift @INC, '../lib';
6     $ENV{PERL5LIB} = '../lib';
7 }
8
9 print "1..12\n";
10
11 my $test = 1;
12
13 sub ok {
14     my ($got,$expect) = @_;
15     print "# expected [$expect], got [$got]\nnot " if $got ne $expect;
16     print "ok $test\n";
17 }
18
19 {
20     use utf8;
21     $_ = ">\x{263A}<"; 
22     s/([\x{80}-\x{10ffff}])/"&#".ord($1).";"/eg; 
23     ok $_, '>&#9786;<';
24     $test++;
25
26     $_ = ">\x{263A}<"; 
27     my $rx = "\x{80}-\x{10ffff}";
28     s/([$rx])/"&#".ord($1).";"/eg; 
29     ok $_, '>&#9786;<';
30     $test++;
31
32     $_ = ">\x{263A}<"; 
33     my $rx = "\\x{80}-\\x{10ffff}";
34     s/([$rx])/"&#".ord($1).";"/eg; 
35     ok $_, '>&#9786;<';
36     $test++;
37
38     $_ = "alpha,numeric"; 
39     m/([[:alpha:]]+)/; 
40     ok $1, 'alpha';
41     $test++;
42
43     $_ = "alphaNUMERICstring";
44     m/([[:^lower:]]+)/; 
45     ok $1, 'NUMERIC';
46     $test++;
47
48     $_ = "alphaNUMERICstring";
49     m/(\p{Ll}+)/; 
50     ok $1, 'alpha';
51     $test++;
52
53     $_ = "alphaNUMERICstring"; 
54     m/(\p{Lu}+)/; 
55     ok $1, 'NUMERIC';
56     $test++;
57
58     $_ = "alpha,numeric"; 
59     m/([\p{IsAlpha}]+)/; 
60     ok $1, 'alpha';
61     $test++;
62
63     $_ = "alphaNUMERICstring";
64     m/([^\p{IsLower}]+)/; 
65     ok $1, 'NUMERIC';
66     $test++;
67
68     $_ = "alpha123numeric456"; 
69     m/([\p{IsDigit}]+)/; 
70     ok $1, '123';
71     $test++;
72
73     $_ = "alpha123numeric456"; 
74     m/([^\p{IsDigit}]+)/; 
75     ok $1, 'alpha';
76     $test++;
77
78     $_ = ",123alpha,456numeric"; 
79     m/([\p{IsAlnum}]+)/; 
80     ok $1, '123alpha';
81     $test++;
82 }