/[pub]/suikawiki/script/t/name.t
Suika

Contents of /suikawiki/script/t/name.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Thu Apr 1 04:46:59 2004 UTC (20 years, 7 months ago) by wakaba
Branch: MAIN
CVS Tags: suikawiki3-redirect, release-3-0-0, HEAD
Branch point for: paragraph-200404, helowiki, helowiki-2005
Changes since 1.1: +49 -1 lines
File MIME type: application/x-troff
New test added

1 #!/usr/bin/perl
2 use strict;
3 use SuikaWiki::Name;
4 use Test;
5
6 plan tests => 25;
7
8 my $name = SuikaWiki::Name->new ([qw/A B C D E F/]);
9 ok $name->stringify (delimiter => q(//)), q(A//B//C//D//E//F);
10
11 $name = SuikaWiki::Name->new (bless [qw/A B C 0 1 2/], 'SomeModule');
12 ok $name->stringify (delimiter => q(!)), q(A!B!C!0!1!2);
13
14 $name = SuikaWiki::Name->new (bless {a => [qw/_ _ _/]}, 'SomeOtherModule');
15 ok $name->stringify (delimiter => q(@)), q(_@_@_);
16
17 $name = SuikaWiki::Name->new ('A//B//C', delimiter_reg => qr#//#);
18 ok $name->stringify (delimiter => q(/)), q(A/B/C);
19
20 $name = SuikaWiki::Name->new ('A B C D', wiki => {config => {name => {space => {separator_reg => qr#\s#}}}});
21 ok $name->stringify (wiki => {config => {name => {space => {separator => q( - )}}}}), q(A - B - C - D);
22
23 $name->append_component ('a');
24 ok $name->stringify (delimiter => '_'), 'A_B_C_D_a';
25
26 $name->append_component ([qw/b c/]);
27 ok $name->stringify (delimiter => '_'), 'A_B_C_D_a_b_c';
28
29 $name->prepend_component ('1');
30 ok $name->stringify (delimiter => '_'), '1_A_B_C_D_a_b_c';
31
32 $name->prepend_component ([qw/2 3/]);
33 ok $name->stringify (delimiter => '_'), '2_3_1_A_B_C_D_a_b_c';
34
35
36 $name = SuikaWiki::Name->new ([qw/.. 1 2/]);
37 ok $name->absolute (self => '.', parent => '..', base => [qw/5 6/])
38 ->stringify (delimiter => ' '),
39 '5 1 2';
40
41 $name = SuikaWiki::Name->new ([qw/.. .. 1 2/]);
42 ok $name->absolute (self => '.', parent => '..', base => [qw/5 6/])
43 ->stringify (delimiter => ' '),
44 '1 2';
45
46 $name = SuikaWiki::Name->new ([qw/1 2/]);
47 ok $name->absolute (self => '.', parent => '..', base => [qw/5 6/])
48 ->stringify (delimiter => ' '),
49 '1 2';
50
51 $name = SuikaWiki::Name->new ([qw/. 1 2/]);
52 ok $name->absolute (self => '.', parent => '..', base => [qw/5 6/])
53 ->stringify (delimiter => ' '),
54 '5 6 1 2';
55
56 $name = SuikaWiki::Name->new ([qw/. . . 1 2/]);
57 ok $name->absolute (self => '.', parent => '..', base => [qw/5 6/])
58 ->stringify (delimiter => ' '),
59 '5 6 1 2';
60
61 ## Root namespace
62
63 $name = SuikaWiki::Name->new ([]);
64 ok $name->stringify (root => '\\'), '\\';
65
66 $name = SuikaWiki::Name->new ([]);
67 ok $name->stringify (wiki => {config => {name => {space => {root => '/'}}}}),
68 '/';
69
70 $name = SuikaWiki::Name->new ('/', root => '/');
71 ok $name->stringify (root => '\\'), '\\';
72
73 $name = SuikaWiki::Name->new ('/', wiki => {config => {name => {space => {root => '/'}}}});
74 ok $name->stringify (root => '\\'), '\\';
75
76 $name = SuikaWiki::Name->new ('', root => '/', delimiter => ':');
77 ok $name->stringify (root => '\\', delimiter => '/'), '\\';
78
79 $name = SuikaWiki::Name->new ([]);
80 ok $name->absolute (self => '.', parent => '..', base => [qw/5 6/])
81 ->stringify (delimiter => ' ', root => '/'),
82 '/';
83
84 $name = SuikaWiki::Name->new ([]);
85 ok $name->absolute (self => '.', parent => '..', base => [])
86 ->stringify (delimiter => ' ', root => '/'),
87 '/';
88
89 $name = SuikaWiki::Name->new ([qw/. . a/]);
90 ok $name->absolute (self => '.', parent => '..', base => [])
91 ->stringify (delimiter => ' ', root => '/'),
92 'a';
93
94 $name = SuikaWiki::Name->new ([qw/.. .. a/]);
95 ok $name->absolute (self => '.', parent => '..', base => [])
96 ->stringify (delimiter => ' ', root => '/'),
97 'a';
98
99 $name = SuikaWiki::Name->new ([qw/a/]);
100 ok $name->absolute (self => '.', parent => '..', base => [])
101 ->stringify (delimiter => ' ', root => '/'),
102 'a';
103
104 $name = SuikaWiki::Name->new ([qw/a b/]);
105 ok $name->absolute (self => '.', parent => '..', base => [])
106 ->stringify (delimiter => ' ', root => '/'),
107 'a b';
108
109 package SomeOtherModule;
110 use overload '@{}' => sub {shift->{a}};

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24