/[suikacvs]/perl/charclass/t/xml.t
Suika

Contents of /perl/charclass/t/xml.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Sat Feb 14 11:27:44 2004 UTC (20 years, 9 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +9 -5 lines
File MIME type: application/x-troff
Error occurred while calculating annotation data.
New test

1 use strict;
2
3 require Test::Simple;
4 my $case = 0;
5
6 my $err;
7
8 my @test = (
9 sub {
10 eval q{use Char::Class::XML qw/InXMLNameChar InXML_NCNameStartChar/; 1} or die $@;
11 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 ok (scalar ($s =~ /^\p{InXMLNameChar}\p{InXMLNameChar}+$/), '^{NameChar}{NameChar}+$');
16 ok (scalar ($s =~ /^\p{InXML_NCNameStartChar}\p{InXMLNameChar}*$/), '^{NameStartChar}{NameChar}*$');
17 }, 1..4,
18 sub {
19 package foo;
20 eval q{use Char::Class::XML qw/InXML_NameStartChar InXMLNameChar/; 1} or die $@;
21 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 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 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 1; # $Date: 2003/09/07 02:52:04 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24