App-Framework
view release on metacpan or search on metacpan
t/02-Options-3.t view on Meta::CPAN
#!/usr/bin/perl
#
use strict ;
use Test::More;
use App::Framework ;
# VERSION
our $VERSION = '1.234' ;
my $DEBUG=0;
my $VERBOSE=0;
my $stdout="" ;
my $stderr="" ;
diag( "Testing options expanded variables" );
## run time options
my %expected_options = (
'test_name=s' => 'this is different',
'default=s' => 'this is different',
'default2=s' => 'my def',
'default3=s' => 'my def another default',
'log=s' => 'another default',
'dbg-namestuff=s' => 'this is different this is different',
) ;
plan tests => 1 + 2*scalar(keys %expected_options) ;
# @ARGV = ('-default', 'this is different') ;
push @ARGV, ('-default', 'this is different') ;
push @ARGV, ('-default2', 'my def') ;
App::Framework->new(
'feature_config' => {
'Options' => {'debug' => 2,},
'Pod' => {'debug' => 2,},
}
)->go() ;
#=================================================================================
# SUBROUTINES EXECUTED BY APP
#=================================================================================
#----------------------------------------------------------------------
# Main execution
#
sub app
{
my ($app, $opts_href, $args_href) = @_ ;
# Check options
my %opts = $app->options() ;
# Check options alias
my %opts2 = $app->Options() ;
is_deeply(\%opts, \%opts2, "Access alias") ;
$app->prt_data("Options=", $opts_href) ;
$app->prt_data("Args=", $args_href) ;
foreach my $optkey (keys %expected_options)
{
my $opt = $optkey ;
my $num=1 ;
if ($opt =~ /([\w\-]+)=/)
{
$opt = $1 ;
$num=0;
}
ok(exists($opts{$opt}), "Test for $opt") ;
( run in 0.417 second using v1.01-cache-2.11-cpan-39bf76dae61 )