|
Revision 25690, 0.9 kB
(checked in by miyagawa, 4 years ago)
|
|
Added Path::Class::File->ufile
|
| Line | |
|---|
| 1 | use strict; |
|---|
| 2 | use Test::Base; |
|---|
| 3 | |
|---|
| 4 | use Path::Class; |
|---|
| 5 | use Path::Class::Unicode; |
|---|
| 6 | plan tests => 5 * blocks; |
|---|
| 7 | |
|---|
| 8 | filters 'chomp', 'eval_str'; |
|---|
| 9 | sub eval_str { eval '"' . shift() . '"' } |
|---|
| 10 | |
|---|
| 11 | run { |
|---|
| 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 |
|---|
| 33 | bob/john.txt |
|---|
| 34 | --- expected |
|---|
| 35 | file:bob/john.txt |
|---|
| 36 | --- local_utf8 |
|---|
| 37 | john.txt |
|---|
| 38 | --- local_cp932 |
|---|
| 39 | john.txt |
|---|
| 40 | |
|---|
| 41 | === |
|---|
| 42 | --- input |
|---|
| 43 | /path/foo/\x{30c6}\x{30b9}\x{30c8}.txt |
|---|
| 44 | --- expected |
|---|
| 45 | file:///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 |
|---|