File: 07_hashes.t

package info (click to toggle)
libdata-streamdeserializer-perl 0.06-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 728 kB
  • sloc: perl: 660; makefile: 3
file content (43 lines) | stat: -rw-r--r-- 920 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl

use warnings;
use strict;
use utf8;
use open qw(:std :utf8);
use lib qw(blib/lib blib/arch);

use Test::More tests    => 5;
use Encode qw(decode encode);


BEGIN {
    my $builder = Test::More->builder;
    binmode $builder->output,         ":utf8";
    binmode $builder->failure_output, ":utf8";
    binmode $builder->todo_output,    ":utf8";

    use_ok 'Data::StreamDeserializer';
}


my $str = q^
    { "a" => "b", "a" => { "c" => 'd'} }
^;

my $dsr = new Data::StreamDeserializer data => $str;
1 until $dsr->next;

my $res = $dsr->result;
ok 1 == keys %$res, "Hash parsed properly";
ok $res->{a}{c} eq 'd', "Last value overlaps the first";

$str = q^
    { "a" => [ 1, 3, 4 ], "a" => { "c" => "d" } }
^;

$dsr = new Data::StreamDeserializer data => $str;
1 until $dsr->next;

$res = $dsr->result;
ok 1 == keys %$res, "Hash parsed properly";
ok $res->{a}{c} eq 'd', "Last value overlaps the first";