Advanced-Config
view release on metacpan or search on metacpan
t/70-validate_date_vars.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use File::Basename;
use File::Spec;
use Sys::Hostname;
use Fred::Fish::DBUG 2.09 qw / on /;
use Fred::Fish::DBUG::Test 2.09;
# How to find the helper module ...
BEGIN { push (@INC, File::Spec->catdir (".", "t", "test-helper")); }
use helper1234;
# ---------------------------------------------------------------------
# Shows what happens when you start monkeying arround with the special
# date variables ...
# ---------------------------------------------------------------------
# Warning: Some tests will fail if this program starts before midnight
# and finishes after midnight. So all tests are disabled
# starting at 11:58 PM.
# ---------------------------------------------------------------------
my $fish;
BEGIN {
$fish = turn_fish_on_off_for_advanced_config ();
unlink ( $fish );
DBUG_ENTER_FUNC ();
use_ok ("Advanced::Config");
DBUG_VOID_RETURN ();
}
END {
DBUG_ENTER_FUNC ();
# Don't do any tests in the END block ...
DBUG_VOID_RETURN ();
}
# ====================================================================
# Start of the main program!
# ====================================================================
{
# Turn fish on ...
DBUG_PUSH ( $fish );
DBUG_ENTER_FUNC (@ARGV);
dbug_ok (1, "In the MAIN program ..."); # Test # 2 ...
my $now = time ();
my ($hr1, $min1, $sec1) = (localtime ($now))[2,1,0];
my ($hr2, $min2, $sec2) = (localtime ($now + 240))[2,1,0];
# If 4 minutes in the future is tomorrow ...
# Skip all tests so that the smoke testers won't complain!
if ( $hr1 > $hr2 ) {
dbug_ok (1, "Skipping all date tests. The current time is too close to midnight! ($hr1:$min1:$sec1, $hr2:$min2:$sec2)");
done_testing ();
DBUG_LEAVE (0);
}
my @cfgs;
DBUG_PRINT ("====", "%s", "="x50);
foreach my $opt ( {}, { date_sep => "/", date_order => 1 },
{ date_sep => ".", date_order => 2, month_type => 2 },
{ date_sep => "", date_order => 0, month_type => 0 },
{ date_sep => " ", date_order => 1, month_type => 1 }
) {
my $cfg = my_load_config ( 1, "70-date-validation.cfg", undef, undef, $opt );
push (@cfgs, $cfg);
}
# Sourcing in files with same/different date formats for the special date vars ...
my $cfg = my_load_config ( 1, "70-date-validation_2.cfg" );
push (@cfgs, $cfg);
( run in 1.062 second using v1.01-cache-2.11-cpan-39bf76dae61 )