1 |
wakaba |
1.1 |
use strict; |
2 |
|
|
|
3 |
|
|
require Test::Simple; |
4 |
|
|
my $case = 0; |
5 |
|
|
|
6 |
|
|
my $err; |
7 |
|
|
|
8 |
|
|
my @test = ( |
9 |
|
|
sub { |
10 |
wakaba |
1.2 |
eval q{use Char::Class::XML qw/InXMLNameChar InXML_NCNameStartChar/; 1} or die $@; |
11 |
wakaba |
1.1 |
my $s = 'NAME'; |
12 |
|
|
ok (scalar ($s =~ /\p{InXMLNameChar}/), '{NameChar}'); |
13 |
|
|
ok (scalar ($s =~ /\p{InXMLNameChar}+/), '{NameChar}+'); |
14 |
|
|
ok (scalar ($s =~ /^\p{InXMLNameChar}+$/), '^{NameChar}+$'); |
15 |
wakaba |
1.2 |
ok (scalar ($s =~ /^\p{InXMLNameChar}\p{InXMLNameChar}+$/), '^{NameChar}{NameChar}+$'); |
16 |
|
|
ok (scalar ($s =~ /^\p{InXML_NCNameStartChar}\p{InXMLNameChar}*$/), '^{NameStartChar}{NameChar}*$'); |
17 |
|
|
}, 1..4, |
18 |
wakaba |
1.1 |
sub { |
19 |
|
|
package foo; |
20 |
wakaba |
1.2 |
eval q{use Char::Class::XML qw/InXML_NameStartChar InXMLNameChar/; 1} or die $@; |
21 |
wakaba |
1.1 |
my $s = 'NAME'; |
22 |
|
|
main::ok (scalar ($s =~ /\p{InXML_NameStartChar}/), '{foo::NameStartChar}'); |
23 |
|
|
main::ok (scalar ($s =~ /\p{InXML_NameStartChar}+/), '{foo::NameStartChar}+'); |
24 |
|
|
main::ok (scalar ($s =~ /^\p{InXML_NameStartChar}+$/), '^{foo::NameStartChar}+$'); |
25 |
wakaba |
1.2 |
main::ok (scalar ($s =~ /^\p{InXMLNameChar}\p{InXMLNameChar}+$/), '^{NameChar}{NameChar}+$'); |
26 |
|
|
main::ok (scalar ($s =~ /^\p{InXML_NameStartChar}\p{InXMLNameChar}*$/), '^{NameStartChar}{NameChar}*$'); |
27 |
|
|
}, 1..4, |
28 |
wakaba |
1.1 |
sub { |
29 |
|
|
eval q{use Char::Class::XML qw/InXMLNCNameChar InXML_NCNameStartChar/; 1} |
30 |
|
|
or die $@; |
31 |
|
|
my $s = 'NAME'; |
32 |
|
|
my $ncname = qr/\p{InXML_NCNameStartChar}\p{InXMLNCNameChar}*/; |
33 |
|
|
ok (scalar ($s =~ /^$ncname$/), 'ncname check'); |
34 |
|
|
ok (scalar ($s =~ /^$ncname(?::$ncname)?$/), 'qname check'); |
35 |
|
|
|
36 |
|
|
$s = qq(NAME\x{4E00}\x{8123}); |
37 |
|
|
ok (scalar ($s =~ /^$ncname$/), 'ncname check'); |
38 |
|
|
ok (scalar ($s =~ /^$ncname(?::$ncname)?$/), 'qname check'); |
39 |
|
|
|
40 |
|
|
$s = qq(foo:bar); |
41 |
|
|
ok (!scalar ($s =~ /^$ncname$/), 'ncname check'); |
42 |
|
|
ok (scalar ($s =~ /^$ncname(?::$ncname)?$/), 'qname check'); |
43 |
|
|
},'','','','','', |
44 |
|
|
); |
45 |
|
|
$case += @test; |
46 |
|
|
$case += @test; |
47 |
|
|
|
48 |
|
|
Test::Simple->import (tests => $case); |
49 |
|
|
|
50 |
|
|
for (1,2) { |
51 |
|
|
for (@test) {&$_ if ref $_} |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
=head1 LICENSE |
56 |
|
|
|
57 |
|
|
Copyright 2003 Wakaba <w@suika.fam.cx> |
58 |
|
|
|
59 |
|
|
This program is free software; you can redistribute it and/or |
60 |
|
|
modify it under the same terms as Perl itself. |
61 |
|
|
|
62 |
|
|
=cut |
63 |
|
|
|
64 |
wakaba |
1.2 |
1; # $Date: 2003/09/07 02:52:04 $ |