summaryrefslogtreecommitdiff
path: root/cpan/CPAN-Meta/t/converter-fail.t
diff options
context:
space:
mode:
authorDavid Golden <dagolden@cpan.org>2011-02-15 22:35:53 -0500
committerDavid Golden <dagolden@cpan.org>2011-02-15 22:50:32 -0500
commitc05760c68edc298aadab73da2781ba0fe1cf24b6 (patch)
tree8fc3142573184b24aadc4c3dea70f1afd6d67f64 /cpan/CPAN-Meta/t/converter-fail.t
parent279627b48dfab08c484fbbb6c05d3964fa9529d2 (diff)
downloadperl-c05760c68edc298aadab73da2781ba0fe1cf24b6.tar.gz
Add CPAN::Meta as a dual-life module
CPAN::Meta version 2.110440 has been added as a dual-life module. It provides a standard library to read, interpret and write CPAN distribution metadata files (e.g. META.json and META.yml) which describes a distribution, its contents, and the requirements for building it and installing it. The latest CPAN distribution metadata specification is included as CPAN::Meta::Spec and notes on changes in the specification over time are given in CPAN::Meta::History. CPAN::Meta is required for CPAN.pm and CPANPLUS to read META.json and MYMETA.json files and is required by Module::Build and ExtUtils::MakeMaker to generate META.json and MYMETA.json files
Diffstat (limited to 'cpan/CPAN-Meta/t/converter-fail.t')
-rw-r--r--cpan/CPAN-Meta/t/converter-fail.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/cpan/CPAN-Meta/t/converter-fail.t b/cpan/CPAN-Meta/t/converter-fail.t
new file mode 100644
index 0000000000..3a82f2d5af
--- /dev/null
+++ b/cpan/CPAN-Meta/t/converter-fail.t
@@ -0,0 +1,39 @@
+use strict;
+use warnings;
+use Test::More 0.88;
+
+use CPAN::Meta;
+use CPAN::Meta::Validator;
+use CPAN::Meta::Converter;
+use File::Spec;
+use IO::Dir;
+use Parse::CPAN::Meta 1.4400;
+
+my $data_dir = IO::Dir->new( 't/data-fail' );
+my @files = sort grep { /^\w/ } $data_dir->read;
+
+sub _spec_version { return $_[0]->{'meta-spec'}{version} || "1.0" }
+
+use Data::Dumper;
+
+for my $f ( reverse sort @files ) {
+ my $path = File::Spec->catfile('t','data-fail',$f);
+ my $original = Parse::CPAN::Meta->load_file( $path );
+ ok( $original, "loaded invalid $f" );
+ my $original_v = _spec_version($original);
+ # UPCONVERSION
+ if ( _spec_version( $original ) lt '2' ) {
+ my $cmc = CPAN::Meta::Converter->new( $original );
+ eval { $cmc->convert( version => 2 ) };
+ ok ( $@, "error thrown up converting" );
+ }
+ # DOWNCONVERSION
+ if ( _spec_version( $original ) gt '1.0' ) {
+ my $cmc = CPAN::Meta::Converter->new( $original );
+ eval { $cmc->convert( version => '1.0' ) };
+ ok ( $@, "error thrown down converting" );
+ }
+}
+
+done_testing;
+