1 |
wakaba |
1.1 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use SuikaWiki::Name; |
4 |
|
|
use Test; |
5 |
|
|
|
6 |
|
|
plan tests => 9; |
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 |
|
|
package SomeOtherModule; |
62 |
|
|
use overload '@{}' => sub {shift->{a}}; |