| 1 |
# Testing of some API methods; |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use lib 't/lib/'; |
| 7 |
use Test::More 0.88; |
| 8 |
use SubtestCompat; |
| 9 |
use TestBridge; |
| 10 |
use CPAN::Meta::YAML; |
| 11 |
|
| 12 |
subtest "default exports" => sub { |
| 13 |
ok( defined(&Load), 'Found exported Load function' ); |
| 14 |
ok( defined(&Dump), 'Found exported Dump function' ); |
| 15 |
ok( \&main::Load == \&CPAN::Meta::YAML::Load, 'Load is CPAN::Meta::YAML' ); |
| 16 |
ok( \&main::Dump == \&CPAN::Meta::YAML::Dump, 'Dump is CPAN::Meta::YAML' ); |
| 17 |
ok( !defined(&LoadFile), 'LoadFile function not exported' ); |
| 18 |
ok( !defined(&DumpFile), 'DumpFile function not exported' ); |
| 19 |
ok( !defined(&freeze), 'freeze function not exported' ); |
| 20 |
ok( !defined(&thaw), 'thaw functiona not exported' ); |
| 21 |
}; |
| 22 |
|
| 23 |
subtest "all exports" => sub { |
| 24 |
package main::all_exports; |
| 25 |
use Test::More; |
| 26 |
use CPAN::Meta::YAML qw/Load Dump LoadFile DumpFile freeze thaw/; |
| 27 |
ok( defined(&Load), 'Found exported Load function' ); |
| 28 |
ok( defined(&Dump), 'Found exported Dump function' ); |
| 29 |
ok( defined(&LoadFile), 'Found exported LoadFile function' ); |
| 30 |
ok( defined(&DumpFile), 'Found exported DumpFile function' ); |
| 31 |
ok( defined(&freeze), 'Found exported freeze function' ); |
| 32 |
ok( defined(&thaw), 'Found exported thaw functiona' ); |
| 33 |
}; |
| 34 |
|
| 35 |
subtest "constructor and documents" => sub { |
| 36 |
my @docs = ( { one => 'two' }, { three => 'four' } ); |
| 37 |
ok( my $yaml = CPAN::Meta::YAML->new( @docs ), "constructor" ); |
| 38 |
cmp_deeply( [ @$yaml ], \@docs, "the object is an arrayref of documents" ); |
| 39 |
}; |
| 40 |
|
| 41 |
done_testing; |