CPAN-Meta-YAML
view release on metacpan or search on metacpan
t/10_read.t view on Meta::CPAN
my $got = eval { CPAN::Meta::YAML->read( $file ) };
is( $@, '', "CPAN::Meta::YAML reads without exception" );
SKIP: {
skip( "Shortcutting after failure", 2 ) if $@;
isa_ok( $got, 'CPAN::Meta::YAML' )
or diag "ERROR: " . CPAN::Meta::YAML->errstr;
cmp_deeply( $got, $case->{perl}, "CPAN::Meta::YAML parses correctly" );
}
if ( $case->{utf8} ) {
ok( utf8::is_utf8( $got->[0]->{$case->{utf8}} ), "utf8 decoded" );
}
# test that read method on object is also a constructor
ok( my $got2 = eval { $got->read( $file ) }, "read() object method");
isnt( $got, $got2, "objects are different" );
cmp_deeply( $got, $got2, "objects have same content" );
}
}
#--------------------------------------------------------------------------#
t/12_write.t view on Meta::CPAN
ok( $data = eval { CPAN::Meta::YAML->read( $tempfile ) },
"case $c->{label}: read $short_tempfile" )
or diag "ERROR: " . CPAN::Meta::YAML->errstr;
is( $@, '', "no error caught" );
SKIP : {
skip "no data read", 1 unless $data;
cmp_deeply( $data, [ $c ],
"case $c->{label}: Perl -> File -> Perl roundtrip" );
}
# CPAN::Meta::YAML->read_string on UTF-8 decoded data
ok( $data = eval { CPAN::Meta::YAML->read_string( slurp($tempfile, ":utf8") ) },
"case $c->{label}: read_string on UTF-8 decoded $short_tempfile" );
is( $@, '', "no error caught" );
SKIP : {
skip "no data read", 1 unless $data;
cmp_deeply( $data, [ $c ],
"case $c->{label}: Perl -> File -> Decoded -> Perl roundtrip" );
}
is( scalar @warnings, 0, "case $c->{label}: no warnings caught" )
or diag @warnings;
}
t/README.md view on Meta::CPAN
include `done_testing`. They should use `subtest` for any repetitive testing
that loops over test cases. Callback should check for the expected test
points (see below) and skip a TML block if those points are not available.
The TestUtils library contains utility functions. Testing functions should
not be added here (i.e. nothing that uses Test::More).
## YAML data files in t/data
Files in the t/data directory are intended to test how YAML files are loaded
and decoded and typically need some custom test code to load the file and see
if the result matches expectations (successful or not).
If a real-world YAML file cannot be loaded due to character set encoding
issues, it should be placed in this directory for testing. If a real-world
YAML file is ASCII or UTF-8 encoded, can be decoded successfully, but has
problems in parsing, it should be reduced to the smallest sample of YAML that
demonstrates the parsing problem and added to a .tml file for testing. See
below for more details.
## TestML quick intro
TestML data files are UTF-8 encoded files with a .tml suffix that contain one
or more test "blocks". Each block has a test label, and one or more 'test
points', usually representing input and expected output, and possibly
additional annotations or flags.
( run in 0.372 second using v1.01-cache-2.11-cpan-26ccb49234f )