Commit | Line | Data |
1d411803 |
1 | use strict; |
4e1fb2f8 |
2 | use warnings; |
2c67ae64 |
3 | use Test::More 0.88; |
1d411803 |
4 | use JSON::MaybeXS (); |
5 | |
6 | our @call; |
7 | |
8 | sub Fake::new { bless({}, 'Fake') } |
9 | sub Fake::foo { push @call, a => $_[1] } |
10 | sub Fake::bar { push @call, c => $_[1] } |
11 | |
12 | { |
13 | local $JSON::MaybeXS::JSON_Class = 'Fake'; |
14 | |
15 | my @args = (foo => 'b', bar => 'd'); |
16 | |
17 | foreach my $args (\@args, [ { @args } ]) { |
18 | |
19 | local @call; |
20 | |
21 | my $obj = JSON::MaybeXS->new(@$args); |
22 | |
23 | is(ref($obj), 'Fake', 'Object of correct class'); |
24 | |
25 | is(join(' ', sort @call), 'a b c d', 'Methods called'); |
26 | } |
27 | } |
28 | |
29 | done_testing; |