�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!README000064400000000604152525335600005432 0ustar00 This archive contains the distribution Data-OptList, version 0.110: parse and validate simple name/value option pairs This software is copyright (c) 2006 by Ricardo Signes. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v5.043. t/hash.t000064400000003722152525335600006131 0ustar00#!/usr/bin/perl use strict; use warnings; =head1 TEST PURPOSE These tests test option list expansion (from an option list into a hashref). =cut use Sub::Install; use Test::More tests => 13; BEGIN { use_ok('Data::OptList'); } # let's get a convenient copy to use: Sub::Install::install_sub({ code => 'mkopt_hash', from => 'Data::OptList', as => 'OPTH', }); is_deeply( OPTH(), {}, "empty opt list expands properly", ); is_deeply( OPTH(undef), {}, "undef opt list expands properly", ); is_deeply( OPTH([]), {}, "empty arrayref opt list expands properly", ); is_deeply( OPTH({}), {}, "empty hashref opt list expands properly", ); is_deeply( OPTH([ qw(foo bar baz) ]), { foo => undef, bar => undef, baz => undef }, "opt list of just names expands", ); is_deeply( OPTH([ qw(foo :bar baz) ]), { foo => undef, ':bar' => undef, baz => undef }, "opt list of names expands with :group names", ); is_deeply( OPTH([ foo => { a => 1 }, ':bar', 'baz' ]), { foo => { a => 1 }, ':bar' => undef, baz => undef }, "opt list of names and values expands", ); is_deeply( OPTH([ foo => { a => 1 }, ':bar' => undef, 'baz' ]), { foo => { a => 1 }, ':bar' => undef, baz => undef }, "opt list of names and values expands, ignoring undef", ); is_deeply( OPTH({ foo => { a => 1 }, -bar => undef, baz => undef }, 0, 'HASH'), { foo => { a => 1 }, -bar => undef, baz => undef }, "opt list of names and values expands with must_be", ); is_deeply( OPTH({ foo => { a => 1 }, -bar => undef, baz => undef }, 0, ['HASH']), { foo => { a => 1 }, -bar => undef, baz => undef }, "opt list of names and values expands with [must_be]", ); eval { OPTH({ foo => { a => 1 }, -bar => undef, baz => undef }, 0, 'ARRAY'); }; like($@, qr/HASH-ref values are not/, "exception tossed on invaild ref value"); eval { OPTH({ foo => { a => 1 }, -bar => undef, baz => undef }, 0, ['ARRAY']); }; like($@, qr/HASH-ref values are not/, "exception tossed on invaild ref value"); t/00-report-prereqs.dd000064400000002661152525335600010542 0ustar00do { my $x = { 'configure' => { 'requires' => { 'ExtUtils::MakeMaker' => '0' }, 'suggests' => { 'JSON::PP' => '2.27300' } }, 'develop' => { 'requires' => { 'Test::More' => '0', 'Test::Pod' => '1.41' } }, 'runtime' => { 'requires' => { 'List::Util' => '0', 'Params::Util' => '0', 'Sub::Install' => '0.921', 'strict' => '0', 'warnings' => '0' } }, 'test' => { 'recommends' => { 'CPAN::Meta' => '2.120900' }, 'requires' => { 'ExtUtils::MakeMaker' => '0', 'File::Spec' => '0', 'Test::More' => '0.96' } } }; $x; }t/00-report-prereqs.t000064400000012742152525335600010417 0ustar00#!/usr/bin/perl use strict; use warnings; # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.024 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec; # from $version::LAX my $lax_version_re = qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | (?:\.[0-9]+) (?:_[0-9]+)? ) | (?: v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? ) )/x; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic # Verify requirements? my $DO_VERIFY_PREREQS = 1; sub _max { my $max = shift; $max = ( $_ > $max ) ? $_ : $max for @_; return $max; } sub _merge_prereqs { my ($collector, $prereqs) = @_; # CPAN::Meta::Prereqs object if (ref $collector eq $cpan_meta_pre) { return $collector->with_merged_prereqs( CPAN::Meta::Prereqs->new( $prereqs ) ); } # Raw hashrefs for my $phase ( keys %$prereqs ) { for my $type ( keys %{ $prereqs->{$phase} } ) { for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; } } } return $collector; } my @include = qw( ); my @exclude = qw( ); # Add static prereqs to the included modules list my $static_prereqs = do 't/00-report-prereqs.dd'; # Merge all prereqs (either with ::Prereqs or a hashref) my $full_prereqs = _merge_prereqs( ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), $static_prereqs ); # Add dynamic prereqs to the included modules list (if we can) my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; if ( $source && $HAS_CPAN_META ) { if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } } else { $source = 'static metadata'; } my @full_reports; my @dep_errors; my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; # Add static includes into a fake section for my $mod (@include) { $req_hash->{other}{modules}{$mod} = 0; } for my $phase ( qw(configure build test runtime develop other) ) { next unless $req_hash->{$phase}; next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); for my $type ( qw(requires recommends suggests conflicts modules) ) { next unless $req_hash->{$phase}{$type}; my $title = ucfirst($phase).' '.ucfirst($type); my @reports = [qw/Module Want Have/]; for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { next if $mod eq 'perl'; next if grep { $_ eq $mod } @exclude; my $file = $mod; $file =~ s{::}{/}g; $file .= ".pm"; my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; my $want = $req_hash->{$phase}{$type}{$mod}; $want = "undef" unless defined $want; $want = "any" if !$want && $want == 0; my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; if ($prefix) { my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); $have = "undef" unless defined $have; push @reports, [$mod, $want, $have]; if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { if ( $have !~ /\A$lax_version_re\z/ ) { push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; } elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { push @dep_errors, "$mod version '$have' is not in required range '$want'"; } } } else { push @reports, [$mod, $want, "missing"]; if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { push @dep_errors, "$mod is not installed ($req_string)"; } } } if ( @reports ) { push @full_reports, "=== $title ===\n\n"; my $ml = _max( map { length $_->[0] } @reports ); my $wl = _max( map { length $_->[1] } @reports ); my $hl = _max( map { length $_->[2] } @reports ); if ($type eq 'modules') { splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; } else { splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; } push @full_reports, "\n"; } } } if ( @full_reports ) { diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( @dep_errors ) { diag join("\n", "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", "The following REQUIRED prerequisites were not satisfied:\n", @dep_errors, "\n" ); } pass; # vim: ts=4 sts=4 sw=4 et: t/mkopt.t000064400000013242152525335600006336 0ustar00#!/usr/bin/perl -T use strict; use warnings; =head1 TEST PURPOSE These tests test option list cannonization (from an option list into a aref). =cut use Data::OptList; use Sub::Install; use Test::More 0.88; # let's get a convenient copy to use: Sub::Install::install_sub({ code => 'mkopt', from => 'Data::OptList', }); sub OPT { # specifying moniker is tedious (also, these tests predate them) splice @_, 1, 0, 'test' if @_ > 1; mkopt(@_); } is_deeply( OPT([]), [], "empty opt list expands properly", ); is_deeply( OPT(), [], "undef expands into []", ); is_deeply( OPT([ qw(foo bar baz) ]), [ [ foo => undef ], [ bar => undef ], [ baz => undef ] ], "opt list of just names expands", ); { my $options = OPT({ foo => undef, bar => 10, baz => [] }); $options = [ sort { $a->[0] cmp $b->[0] } @$options ]; is_deeply( $options, [ [ bar => undef ], [ baz => [] ], [ foo => undef ] ], "hash opt list expands properly" ); } is_deeply( OPT([ qw(foo bar baz) ], 0, "ARRAY"), [ [ foo => undef ], [ bar => undef ], [ baz => undef ] ], "opt list of just names expands with must_be", ); is_deeply( OPT([ qw(foo :bar baz) ]), [ [ foo => undef ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names expands with :group names", ); is_deeply( OPT([ foo => { a => 1 }, ':bar', 'baz' ]), [ [ foo => { a => 1 } ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands", ); is_deeply( OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, 'HASH'), [ [ foo => { a => 1 } ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands with must_be", ); is_deeply( OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, ['HASH']), [ [ foo => { a => 1 } ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands with [must_be]", ); is_deeply( OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, [qw< HASH CODE >]), [ [ foo => { a => 1 } ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands with [must_be]", ); is_deeply( OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, [qw< CODE HASH >]), [ [ foo => { a => 1 } ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands with [must_be]", ); { bless((my $object = {}), 'Test::DOL::Obj'); is_deeply( OPT([ foo => $object, ':bar', 'baz' ], 0, 'Test::DOL::Obj'), [ [ foo => $object ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands with must_be, must_be object", ); is_deeply( OPT([ foo => $object, ':bar', 'baz' ], 0, ['Test::DOL::Obj']), [ [ foo => $object ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands with [must_be], must_be object", ); is_deeply( OPT([ foo => $object, ':bar', 'baz' ], 0, ['ARRAY', 'HASH', 'CODE', 'SCALAR', 'Test::DOL::Obj']), [ [ foo => $object ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands with [must_be], must_be object", ); is_deeply( OPT([ foo => $object, ':bar', 'baz' ], 0, ['Test::DOL::Obj', 'CODE']), [ [ foo => $object ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands with [must_be], must_be object", ); } eval { OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, 'ARRAY'); }; like($@, qr/HASH-ref values are not/, "exception tossed on invalid ref value"); eval { OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, ['ARRAY']); }; like($@, qr/HASH-ref values are not/, "exception tossed on invalid ref value"); eval { OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, ['ARRAY', 'CODE', 'SCALAR', 'Foo']); }; like($@, qr/HASH-ref values are not/, "exception tossed on invalid ref value"); eval { mkopt( [ foo => { a => 1 }, ':bar', 'baz' ], { moniker => 'test', must_be => ['ARRAY'], } ); }; like($@, qr/HASH-ref values are not/, "exception tossed on invalid ref value"); eval { OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, 'Test::DOL::Obj'); }; like($@, qr/HASH-ref values are not/, "exception tossed on invalid ref value"); eval { OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, ['Test::DOL::Obj']); }; like($@, qr/HASH-ref values are not/, "exception tossed on invalid ref value"); eval { OPT([ foo => { a => 1 }, ':bar', 'baz' ], 0, ['CODE', 'Test::DOL::Obj']); }; like($@, qr/HASH-ref values are not/, "exception tossed on invalid ref value"); is_deeply( OPT([ foo => { a => 1 }, ':bar' => undef, 'baz' ]), [ [ foo => { a => 1 } ], [ ':bar' => undef ], [ baz => undef ] ], "opt list of names and values expands, ignoring undef", ); eval { OPT([ foo => { a => 1 }, ':bar' => undef, ':bar' ], 1); }; like($@, qr/multiple definitions/, "require_unique constraint catches repeat"); is_deeply( OPT([ foo => { a => 1 }, ':bar' => undef, 'baz' ], 1), [ [ foo => { a => 1 } ], [ ':bar' => undef ], [ baz => undef ] ], "previously tested expansion OK with require_unique", ); # This one is complicated. We defined name values as only non-references (the # default) or arrayrefs, so arrayrefs are not turned into values as they # usually are. (The subsequent test shows the default expectation.) # -- rjbs, 2011-04-08 my @input =( foo => { a => 1 }, bar => undef, baz => xyz => [ 1, 2, 3 ], ); is_deeply( mkopt( [ @input ], { moniker => 'test', name_test => sub { ! ref $_[0] or Params::Util::_ARRAYLIKE($_[0]) }, }, ), [ [ foo => { a => 1 } ], [ bar => undef ], [ baz => undef ], [ xyz => undef ], [ [ 1, 2, 3 ], undef ], ], ); is_deeply( mkopt( [ @input ], { moniker => 'test', }, ), [ [ foo => { a => 1 } ], [ bar => undef ], [ baz => undef ], [ xyz => [ 1, 2, 3 ] ], ], ); done_testing; Changes000064400000002717152525335600006054 0ustar00Revision history for Sub-Exporter 0.110 2016-03-24 21:20:54-04:00 America/New_York - major optimization to mkopt (thanks, Olivier Mengué) 0.109 2013-12-13 08:30:34 America/New_York update bugtracker and repo links 0.108 2013-07-05 21:43:56 America/New_York repackage, new bug tracker 0.107 2011-05-06 11:24:45 America/New_York mkopt now prefers named parameters; docs updated added the name_test parameter to mkopt 0.106 2010-02-14 correct version style mismatch for Sub::Install (thanks, brian d foy) 0.105 2010-01-14 fix a typo in documenation (thanks, Florian Ragwitz) 0.104 2009-01-16 add repo info to metadata 0.103 2007-11-01 require taint-safe Test::Pod 0.102 2006-07-04 improved documentation tweaked some Perl::Critic-offending code 0.100 2006-06-05 broken out of Sub-Exporter into its own dist renamed routines to be easier to type 0.040 2006-05-11 (part of Sub-Exporter) tweaks to Data::OptList, moving toward its own dist: now it exports expand_opt_list is now opt_list_as_hash 0.??? 2006-05-10 (part of Sub-Exporter) require Params::Util for craftier opt list validation 0.??? 2006-04-26 (part of Sub-Exporter) broken out of Sub::Exporter module remove an "optimization" that broke expand_opt_list