YAML::Tests - Common Test Suite for Perl YAML Implementations
> yt -MYAML::Foo # Run all YAML Tests against YAML::Foo implementation
> export PERL_YAML_TESTS_MODULE=YAML::Foo > yt
YAML-Tests defines a number of implementation independent tests that can be used to test various YAML modules.
There are two ways to use YAML-Tests. If you are the author of a Perl YAML module, you can add the line:
Makefile.PL. This will copy the tests from YAML::Tests into your module's test area.
If you are Just Another Perl Hacker, YAML-Tests installs a command line tool called
yt to run the YAML tests against a specific module. Like this:
> yt -MYAML::Syck
YAML::Tests provides a common test suite against which to test Perl YAML modules. It also provides a Module::Install component (
use_yaml_tests) to make it simple for YAML module authors to include the tests in their distributions. See Module::Install::YAML::Tests for more information about this feature.
This module installs a command line tool called
yt which can be used to run the YAML tests against various implementations. See yt for more information.
YAML::Tests provides tests that should pass on any YAML implementation that provides a
Load function interface. These are likely not the only tests that an implementation should have. They are intended to be a common subset.
This section describes the types of tests that are provided.
"NYN Roundtripping" is a YAML term that means Native->YAML->Native. In our case "Native" means "Perl". These tests take various Perl objects, Dump them to YAML and then Load them back into Perl. The original and the clone Perl objects are compared for equivalence.
This is a very common type of test.
"YNY" means YAML->Native->YAML. Load a YAML stream to Perl and Dump it back to YAML. Test if the YAML streams match.
There are fewer of these tests because there are usually variations in how a Dumper implementation will actually Dump a given object. Still we can cover the simple basics.
Load a given YAML stream and see if it produces the expected Perl objects.
This is different from NYN because we are testing YAML streams that are not produced by a YAML Dumper. This is where we can test the edge cases that might be produced by a human editing YAML.
Invalid YAML should cause a Loader to throw an error. These tests Load various invalid YAML streams and make sure that an error is thrown.
Some tests make sure that all the
Load functions follow the same API.
Currently there are 4 YAML Implementations on CPAN:
This is the original YAML module written in 2001 by Ingy döt Net. It is pure Perl.
This wrapper of Why The Lucky Stiff's libsyck, was written by Audrey Tang in 2005. YAML::Syck is almost entirely written in C, so it is fast. The libsyck library was written in 2003 and targeted at the YAML 1.0 spec.
YAML::Tiny is a pure Perl module written by Adam Kennedy in 2006. It is an attempt to write a YAML implementation that is as small as possible. It does this by choosing to only deal with a subset of the YAML language. It attempts to support the subset of YAML that is used by popular Perl projects like CPAN and SVK.
This wrapper of Kirill Siminov's libyaml (2005) is a pure C module written by Ingy döt Net in 2007. The libyaml library was targeted at the current YAML 1.1 spec. It was written to match the spec exactly. At this point it has no known bugs. It is meant to eventually become the new YAML.pm codebase.
Ingy döt Net <email@example.com>
Copyright (c) 2007. Ingy döt Net. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.