File: 01_parse_amf0.t

package info (click to toggle)
libdata-amf-perl 0.09%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 544 kB
  • ctags: 527
  • sloc: perl: 5,955; makefile: 14
file content (138 lines) | stat: -rw-r--r-- 1,742 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
use Test::Base;

plan tests => 1 * blocks;

use FindBin;
use File::Spec;

use Data::AMF;

my $amf = Data::AMF->new( version => 0 );

sub load {
    my $file = File::Spec->catfile( $FindBin::Bin, $_[0] );
    open my $fh, "<$file";
    my $data = do { local $/; <$fh> };
    close $fh;

    $data;
}

sub parse {
    my ($obj) = $amf->deserialize($_[0]);

    return { data => $obj };
}

filters {
    input    => [qw/load parse/],
    expected => 'yaml',
};

run_compare;

__DATA__

=== number
--- input: data/amf0/number
--- expected
data: 123

=== boolean true
--- input: data/amf0/boolean_true
--- expected
data: 1

=== boolean false
--- input: data/amf0/boolean_false
--- expected
data: 0

=== string
--- input: data/amf0/string
--- expected
data: foo

=== object
--- input: data/amf0/object
--- expected
data:
  foo: bar

=== object2
--- input: data/amf0/object2
--- expected
data:
  array:
    - foo
    - bar
  hash:
    foo: bar

=== null object
--- input: data/amf0/null_object
--- expected
data: {}

=== null
--- input: data/amf0/null
--- expected
data: ~

=== undefined
--- input: data/amf0/undefined
--- expected
data: ~

=== reference
--- input: data/amf0/reference
--- expected
data:
  obj1:
    foo: bar
  obj2:
    foo: bar

=== nested reference
--- input: data/amf0/reference_nested
--- expected
data:
  obj:
    foo: bar
  obj2:
    foo: bar
  ary:
    - a
    - b
    - c
  nested:
    ary:
      - a
      - b
      - c
    obj:
      foo: bar

=== ecma array
--- input: data/amf0/ecma_array
--- expected
data:
  0: foo
  bar: baz

=== strict-array
--- input: data/amf0/strict_array
--- expected
data:
  - foo
  - bar
  - baz

=== date
--- input: data/amf0/date
--- expected
data: 1216717318745

=== long string
--- SKIP