1# Testing of some API methods; 2 3use strict; 4use warnings; 5 6use lib 't/lib/'; 7use Test::More 0.88; 8use SubtestCompat; 9use TestBridge; 10use CPAN::Meta::YAML; 11 12subtest "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 23subtest "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 35subtest "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 41done_testing; 42