root/lang/perl/Path-Class-URI/trunk/t/02_unicode.t @ 25690

Revision 25690, 0.9 kB (checked in by miyagawa, 4 years ago)

Added Path::Class::File->ufile

Line 
1use strict;
2use Test::Base;
3
4use Path::Class;
5use Path::Class::Unicode;
6plan tests => 5 * blocks;
7
8filters 'chomp', 'eval_str';
9sub eval_str { eval '"' . shift() . '"' }
10
11run {
12    my $block = shift;
13    my $f = ufile( split '/', $block->input );
14    is $f->uri, $block->expected;
15    my $f2 = ufile_from_uri($f->uri);
16    is $f2, $f;
17
18    {
19        local $Path::Class::Unicode::encoding = "utf-8";
20        is file($f2->stringify)->basename, $block->local_utf8;
21
22        local $Path::Class::Unicode::encoding = "cp932";
23        is file($f2->stringify)->basename, $block->local_cp932;
24    }
25
26    is file($f2->stringify)->ufile, $f;
27};
28
29__END__
30
31===
32--- input
33bob/john.txt
34--- expected
35file:bob/john.txt
36--- local_utf8
37john.txt
38--- local_cp932
39john.txt
40
41===
42--- input
43/path/foo/\x{30c6}\x{30b9}\x{30c8}.txt
44--- expected
45file:///path/foo/%E3%83%86%E3%82%B9%E3%83%88.txt
46--- local_utf8
47\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88.txt
48--- local_cp932
49\x83\x65\x83\x58\x83\x67.txt
Note: See TracBrowser for help on using the browser.