File: 04_parse_amf3.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 (106 lines) | stat: -rw-r--r-- 1,591 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
use Test::Base;

plan tests => 1 * blocks;

use FindBin;
use File::Spec;

use Data::AMF;
use Data::AMF::Type::Boolean;
use Data::AMF::Type::Null;

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

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 $obj;
}

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

run_compare;

__DATA__

=== number
--- input: data/amf3/number
--- expected
123.45

=== boolean true
--- input: data/amf3/true
--- expected
Data::AMF::Type::Boolean->new(1)

=== boolean false
--- input: data/amf3/false
--- expected
Data::AMF::Type::Boolean->new(0)

=== string
--- input: data/amf3/string
--- expected
"foo"

=== object
--- input: data/amf3/object
--- expected
{ foo => "bar" }

=== object2
--- input: data/amf3/object2
--- expected
{
	array => [ "foo", "bar" ],
	hash => { foo => "bar" }
}

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

=== array
--- input: data/amf3/array
--- expected
[ "foo", "bar" ]

=== null
--- input: data/amf3/null
--- expected
Data::AMF::Type::Null->new()

=== undefined
--- input: data/amf3/undefined
--- expected
undef

=== date
--- input: data/amf3/date
--- expected
DateTime->new(
	year   => 2009,
	month  => 10,
	day    => 22,
	hour   => 03,
	minute => 34,
	second => 56
)

=== byte_array
--- input: data/amf3/byte_array
--- expected
Data::AMF::Type::ByteArray->new([10, 11, 1, 7, 102, 111, 111, 6, 7, 98, 97, 114, 1])