File: 05_format_amf3_simple.t

package info (click to toggle)
libdata-amf-perl 0.09%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 552 kB
  • ctags: 527
  • sloc: perl: 5,955; makefile: 10
file content (93 lines) | stat: -rw-r--r-- 1,118 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
use Test::Base;

plan tests => 1 * blocks;

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

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

sub serialize {
    $amf->serialize($_[0]);
}

sub deserialize {
    my ($data) = $amf->deserialize($_[0]);
    return { data => $data };
}

filters {
    input => [qw/eval serialize deserialize/],
};

run_compare input => 'input';

__DATA__

=== number
--- input
123.45

=== boolean true
--- input
Data::AMF::Type::Boolean->new(1)

=== boolean false
--- input
Data::AMF::Type::Boolean->new(0)

=== string
--- input
"foo"

=== object
--- input
{ foo => "bar" }

=== null object
--- input
{}

=== complex object
--- input
{
	array => [
		"foo",
		"bar",
		'',
		{
			id => 1,
			name => 'hoge',
		},
		{
			id => 2,
			name => '',
			age => 21,
		},
		{
			id => 3,
			name => 'hoge',
		},
	],
	hash => { foo => "bar" }
}

=== null
--- input
Data::AMF::Type::Null->new()

=== undefined
--- input
undef

=== date
--- input
DateTime->now;

=== byte_array
--- input
Data::AMF::Type::ByteArray->new([1, 2, 3, 4, 5])