File: input_decode.t

package info (click to toggle)
libmessage-passing-perl 0.117-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 544 kB
  • sloc: perl: 2,742; makefile: 2; sh: 1
file content (21 lines) | stat: -rw-r--r-- 469 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
use strict;
use warnings;
use Test::More;
use Try::Tiny;

use Message::Passing::Output::Test;
use Message::Passing::Filter::Decoder::JSON;

my $unpacked;
my $test = Message::Passing::Output::Test->new(cb => sub { $unpacked = shift });
my $decoder = Message::Passing::Filter::Decoder::JSON->new(output_to => $test);

my $h = {};
$decoder->consume($h);;
is_deeply $unpacked, $h;

$decoder->consume('{"baz":"bar"}');
is_deeply $unpacked, {"baz" => "bar"};

done_testing;