File: new.t

package info (click to toggle)
libjson-maybexs-perl 1.004000-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 164 kB
  • sloc: perl: 267; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 532 bytes parent folder | download | duplicates (5)
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
use strict;
use warnings;
use Test::More 0.88;
use JSON::MaybeXS ();

our @call;

sub Fake::new { bless({}, 'Fake') }
sub Fake::foo { push @call, a => $_[1] }
sub Fake::bar { push @call, c => $_[1] }

{
  local $JSON::MaybeXS::JSON_Class = 'Fake';

  my @args = (foo => 'b', bar => 'd');

  foreach my $args (\@args, [ { @args } ]) {

    local @call;

    my $obj = JSON::MaybeXS->new(@$args);

    is(ref($obj), 'Fake', 'Object of correct class');

    is(join(' ', sort @call), 'a b c d', 'Methods called');
  }
}

done_testing;