avoid needing . in @INC in dev mode
[p5sagit/JSON-MaybeXS.git] / t / new.t
CommitLineData
1d411803 1use strict;
4e1fb2f8 2use warnings;
2c67ae64 3use Test::More 0.88;
1d411803 4use JSON::MaybeXS ();
5
6our @call;
7
8sub Fake::new { bless({}, 'Fake') }
9sub Fake::foo { push @call, a => $_[1] }
10sub 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
29done_testing;