Advanced-Config

 view release on metacpan or  search on metacpan

t/40-validate-modifiers.t  view on Meta::CPAN

      my $val1 = $validate->{$_};
      my $val2 = $cfg->get_value ( $_ );
      my $val3 = (defined $val2) ? $val2 : "";
      my $chk  = (defined $val2) && $val1 eq $val2;
      dbug_ok ( $chk, "Validating tag \"$_\" matches config file.  ($val3)" );
      unless ( $chk ) {
         DBUG_PRINT ("ERROR", "Value should have been: %s", $val1);
      }
   }

   # Since I didn't count the test cases, must end my program
   # with a call to this method.  Can't do tests in END anymore!
   done_testing ();

   DBUG_LEAVE (0);
}

# ====================================================================
# All tags defined in the config file must be initialized below!
# The config file is: t/config/40-validate-modifiers.cfg

# NOTE: No tag may have undef as a value!
#       That can't happen in this module if a tag is defined!
#       Undef means the tag doesn't exist instead!

sub init_validation_hash
{
   DBUG_ENTER_FUNC (@_);

   my $Msg  = "Be liberal in what you accept, and conservative in what you send.";
   my $aMsg = "liberal in what you accept, and conservative in what you send.";
   my $bMsg = "send.";
   my $cMsg = "Be liberal in what you accept, and conservative in what you";
   my $dMsg = "Be";

   my $a2Msg = "in what you accept, and conservative in what you send.";
   my $c2Msg = "Be liberal in what you accept, and conservative in what";
   my $e2Msg = "liberal";

   my $sub1 = $Msg;   $sub1 =~ s/in/by/;
   my $sub2 = $Msg;   $sub2 =~ s/in/by/g;
   my $sub5 = $Msg;   $sub5 =~ s/in//;
   my $sub6 = $Msg;   $sub6 =~ s/in//g;

   # Get all variables starting with "y" ...
   # Need in case your environment contains unexpected ${y...} vars.
   my %l;
   foreach ( "yellow", "yesterday", keys %ENV ) {
      $l{$_} = 2  if ( $_ =~ m/^y/ );
   }
   my $lst = join (" ", sort keys %l);

   my %values = (  "msg"  => $Msg,
                   "a"    => $aMsg,
                   "b"    => $bMsg,
                   "c"    => $cMsg,
                   "d"    => $dMsg,
                   "a2"   => $a2Msg,
                   "c2"   => $c2Msg,
                   "e2"   => $e2Msg,
                   "len"  => length ($Msg),

                   "cd"   => "call die",
                   "abcd" => "",
                   "die2" => $Msg,
                   "die3" => "",
                   "die4" => $Msg,

                   "def0" => "The unknown soldier",
                   "def1" => "The unknown soldier.",
                   "def2" => $dMsg,
                   "def3" => "The unknown soldier 2.",
                   "def4" => "",
                   "def5" => $dMsg,

                   "awa"   => "Another",
                   "zebra"    => "A wild animal!",
                   "elephant" => "Another wild animal!",
                   "asgn1" => "A wild animal!",
                   "asgn2" => "A wild animal!",
                   "asgn3" => "Another wild animal!",
                   "asgn4" => "Another wild animal!",

                   "dnu"   => "Do not use",
                   "alt1"  => "",
                   "alt2"  => "Overriding a value is fun!",
                   "alt3"  => "",
                   "alt4"  => "",
                   "alt5"  => "",
                   "alt6"  => "Overriding a value is fun!",
                   "alt7"  => "Do not use!",
                   "alt8"  => "",

                   "yellow"    => "bass",
                   "list1"     => $lst,
                   "list2"     => $lst,
                   "bass"      => "is a fish",
                   "indirect1" => "is a fish",
                   "indirect2" => "",
                   "book"      => "Chapter123",
                   "all"       => "Chapter",

                   "sub_01"    => ${sub1},
                   "sub_02"    => ${sub2},
                   "sub_03"    => "",
                   "sub_04"    => "",
                   "sub_05"    => ${sub5},
                   "sub_06"    => ${sub6},
                   "sub_07"    => ${sub5},
                   "sub_08"    => ${sub6},
                   "sub_09"    => "xxx xxxxx",
                   "sub_10"    => "Yxx xxxxx",
                   "sub_11"    => "xxx xxxxY",
                   "sub_12"    => "xx xxxxx",
                   "sub_13"    => "xxx xxxx",
                   "sub_14"    => " conservative in what you send.",
                   "sub_15"    => " conservative",
                   "sub_16"    => "t you",
                   "sub_17"    => "t you",
                   "sub_18"    => "in what you accept, and conservative",
                   "sub_19"    => "d",



( run in 0.723 second using v1.01-cache-2.11-cpan-39bf76dae61 )