|
Revision 16818, 1.3 kB
(checked in by vkgtaro, 5 years ago)
|
|
文字化けてた
|
| Line | |
|---|
| 1 | use Test::Base; |
|---|
| 2 | use FormValidator::LazyWay; |
|---|
| 3 | use FindBin; |
|---|
| 4 | use File::Spec; |
|---|
| 5 | use CGI; |
|---|
| 6 | use YAML::Syck; |
|---|
| 7 | use lib File::Spec->catfile( $FindBin::Bin, 'lib' ); |
|---|
| 8 | use Data::Dumper; |
|---|
| 9 | use Encode; |
|---|
| 10 | use utf8; |
|---|
| 11 | |
|---|
| 12 | plan tests => 1 * blocks; |
|---|
| 13 | |
|---|
| 14 | run { |
|---|
| 15 | my $block = shift; |
|---|
| 16 | |
|---|
| 17 | my $cgi = new CGI( $block->param ) ; |
|---|
| 18 | |
|---|
| 19 | my $config = Load($block->yaml); |
|---|
| 20 | my $fv = FormValidator::LazyWay->new( config => $config, unicode => 1 ); |
|---|
| 21 | |
|---|
| 22 | # 期待される結果は flagged UTF-8 |
|---|
| 23 | my $expected; |
|---|
| 24 | { |
|---|
| 25 | local $Data::Dumper::Terse = 1; |
|---|
| 26 | $expected = decode('utf8', Dumper($block->expected) ); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | $expected = eval $expected; |
|---|
| 30 | |
|---|
| 31 | is_deeply($fv->config, $expected ); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | __END__ |
|---|
| 35 | === sccess1 |
|---|
| 36 | --- yaml |
|---|
| 37 | rules: |
|---|
| 38 | - String |
|---|
| 39 | setting: |
|---|
| 40 | strict: |
|---|
| 41 | name: |
|---|
| 42 | rule: |
|---|
| 43 | - String#string |
|---|
| 44 | kana: |
|---|
| 45 | rule: |
|---|
| 46 | - String#string |
|---|
| 47 | lang: ja |
|---|
| 48 | labels: |
|---|
| 49 | ja: |
|---|
| 50 | name: 名前 |
|---|
| 51 | kana: カナ |
|---|
| 52 | --- expected eval |
|---|
| 53 | { 'messages' => { 'ja' => { 'rule' => {} } }, |
|---|
| 54 | 'lang' => 'ja', |
|---|
| 55 | 'setting' => { |
|---|
| 56 | 'strict' => { |
|---|
| 57 | 'name' => { 'rule' => [ 'String#string' ] }, |
|---|
| 58 | 'kana' => { 'rule' => [ 'String#string' ] } |
|---|
| 59 | } |
|---|
| 60 | }, |
|---|
| 61 | 'labels' => { |
|---|
| 62 | 'ja' => { |
|---|
| 63 | 'name' => '名前', |
|---|
| 64 | 'kana' => 'カナ' |
|---|
| 65 | } |
|---|
| 66 | }, |
|---|
| 67 | 'rules' => [ 'String' ] |
|---|
| 68 | } |
|---|
| 69 | |
|---|