~ubuntu-branches/ubuntu/saucy/libyaml-libyaml-perl/saucy-security

« back to all changes in this revision

Viewing changes to t/utf8.t

  • Committer: Bazaar Package Importer
  • Author(s): Ryan Niebur
  • Date: 2009-06-01 02:17:22 UTC
  • Revision ID: james.westby@ubuntu.com-20090601021722-8qlj45pmu8ffwzau
Tags: upstream-0.32
Import upstream version 0.32

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use t::TestYAMLTests tests => 8;
 
2
use utf8;
 
3
 
 
4
is Dump("\x{100}"), "--- \xC4\x80\n", 'Dumping wide char works';
 
5
is Load("--- \xC4\x80\n"), "\x{100}", 'Loading UTF-8 works';
 
6
is Load("\xFE\xFF\0-\0-\0-\0 \x01\x00\0\n"), "\x{100}", 'Loading UTF-16BE works';
 
7
is Load("\xFF\xFE-\0-\0-\0 \0\x00\x01\n\0"), "\x{100}", 'Loading UTF-16LE works';
 
8
 
 
9
my $hash = {
 
10
    '店名' => 'OpCafé',
 
11
    '電話' => <<'...',
 
12
03-5277806
 
13
0991-100087
 
14
...
 
15
    Email => 'boss@opcafe.net',
 
16
    '時間' => '11:01~23:59',
 
17
    '地址' => '新竹市 300 石坊街 37-8 號',
 
18
};
 
19
 
 
20
my $yaml = <<'...';
 
21
---
 
22
Email: boss@opcafe.net
 
23
地址: 新竹市 300 石坊街 37-8 號
 
24
店名: OpCafé
 
25
時間: 11:01~23:59
 
26
電話: '03-5277806
 
27
 
 
28
  0991-100087
 
29
 
 
30
'
 
31
...
 
32
 
 
33
utf8::encode($yaml);
 
34
 
 
35
is Dump($hash), $yaml, 'Dumping Chinese hash works';
 
36
is_deeply Load($yaml), $hash, 'Loading Chinese hash works';
 
37
 
 
38
my $hash2 = {
 
39
    'モジュール' => [
 
40
        {
 
41
            '名前' => 'YAML',
 
42
            '作者' => {'名前' => 'インギー', '場所' => 'シアトル'},
 
43
        },
 
44
        {
 
45
            '名前' => 'Plagger',
 
46
            '作者' => {'名前' => '宮川達彦', '場所' => 'サンフランシスコ' },
 
47
        },
 
48
    ]
 
49
};
 
50
 
 
51
my $yaml2 = <<'...';
 
52
---
 
53
モジュール:
 
54
- 作者:
 
55
    名前: インギー
 
56
    場所: シアトル
 
57
  名前: YAML
 
58
- 作者:
 
59
    名前: 宮川達彦
 
60
    場所: サンフランシスコ
 
61
  名前: Plagger
 
62
...
 
63
 
 
64
utf8::encode($yaml2);
 
65
 
 
66
is Dump($hash2), $yaml2, 'Dumping Japanese hash works';
 
67
is_deeply Load($yaml2), $hash2, 'Loading Japanese hash works';