Getopt-Alt

 view release on metacpan or  search on metacpan

t/options-valid.t  view on Meta::CPAN

        negatable => 1,
    },
    'null?' => {
        nullable => 1,
    },
);
my @bulk = get_bulk();

my %valid = @valid;
my $tests = ( sum map {scalar keys %{$valid{$_}} } keys %valid );

my $object = Moose::Meta::Class->create(
    'dummy',
    superclasses => [ 'Getopt::Alt::Dynamic' ],
);

for ( my $i = 0; $i < @valid; $i += 2 ) {
    my $args  = $valid[$i];
    my $tests = $valid[$i+1];
    my $opt   = Getopt::Alt::Option::build_option( $object, $args );

    for my $key ( keys %{ $tests } ) {
        is_deeply( $opt->$key(), $tests->{$key}, "$args -> $tests->{$key}" ) or BAIL_OUT(1);
        #diag Dumper $opt, $opt->$key();
        #diag Dumper $opt->$key(), $tests->{$key};
    }
}

for my $valid (@bulk) {
    my $opt = eval{ Getopt::Alt::Option::build_option( $object, $valid ) };
    diag Dumper $@ if $@;
    ok($opt, "'$valid' loads");
}
done_testing();

sub get_bulk {
    return (
          '1=i%'
        , '256|c=i%'
        , '2=i%'
        , '3=i%'
        , 'add|a=s@'
        , 'add_only|a'
        , 'after|a=s'
        , 'against|a=s'
        , 'all|a'
        , 'all_line|all-line|A'
        , 'apache2|a'
        , 'arg|a=s%'
        , 'ask|a'
        , 'author|a'
        , 'author|authortests|a'
        , 'autocomplete'
        , 'back|trimback|b=s'
        , 'base=s'
        , 'bell|b'
        , 'breaks|b'
        , 'bydate|b'
        , 'bydate|d'
        , 'byte|b'
        , 'calendar_height|height|h=s'
        , 'cat|C'
        , 'change|c=i'
        , 'changer|c=s'
        , 'changes|c=i'
        , 'chdir|d'
        , 'clean|distclean|c'
        , 'cmd|command|c=s'
        , 'col|c=i'
        , 'colour|colourspace|c=s'
        , 'colour_number|cnum=s'
        , 'colour_number_surround|cnumout=s'
        , 'cols|columns|c=s@'
        , 'column|c=s'
        , 'columns|c=i'
        , 'columns|C=i'
        , 'command|c=s'
        , 'config|conf|c=s'
        , 'config|C=s'
        , 'conf=s'
        , 'count|c'
        , 'countdown|c=i'
        , 'count|n'
        , 'cp|cpmissing|m'
        , 'cpu|c'
        , 'create|c'
        , 'current|c'
        , 'database|d=s'
        , 'date|d=s'
        , 'date|d=s%'
        , 'db|d'
        , 'db_host|dbhost|h=s'
        , 'dblong|l'
        , 'db_name|dbname|n=s'
        , 'db_pass|dbpass|u=s'
        , 'db_port|dbport|p=s'
        , 'db_user|dbuser|u=s'
        , 'decending|d'
        , 'delete|d'
        , 'deleted|d=s@'
        , 'describe|d'
        , 'destination|d'
        , 'destination|d=s'
        , 'dict|d=s'
        , 'die|d=i'
        , 'diffargs|a=s'
        , 'diff|d'
        , 'diff|diffcmd|d=s'
        , 'diff|d=s'
        , 'dir|d=s'
        , 'dirfirst|d'
        , 'dirs|dir|d=s@'
        , 'dirs|d=s@'
        , 'display|d=s%'
        , 'dos|d'
        , 'dump|D'
        , 'exclude|e=s'
        , 'Exclude|E=s'
        , 'exists|e'
        , 'expand|e'
        , 'file_contains=s'



( run in 2.334 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )