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