File: tied.t

package info (click to toggle)
libbson-perl 1.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,152 kB
  • sloc: perl: 3,970; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 625 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
use strict;
use warnings;

use Test::More;
use Test::Fatal;
use lib 't/lib';
use lib 't/pvtlib';
use CleanEnv;
use TestTie;

use BSON;

# PERL-737 encoding of simple tied var

ok(my $c = BSON->new, 'got codec object');

my ($number, $str) = (5, 'hello');

my $var;
tie $var, 'TestTie::Scalar';

$var = $number;
my $varnum_bin = $c->encode_one({ mytied => $var });
ok(
    $c->decode_one($varnum_bin)->{'mytied'} == $number,
    'round trip for tie var'
);

$var = $str;
my $varstr_bin = $c->encode_one({ mytied => $var });
is(
    $c->decode_one($varstr_bin)->{'mytied'}, $str,
    'round trip for tie var'
);

done_testing;