Advanced-Config
view release on metacpan or search on metacpan
t/02-basic_parse_line_01_defaults.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
# No precount of the number of tests performed!
use Test::More;
use File::Basename;
use File::Spec;
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;
# Does a test of the parse routines used to parse the config file. (using defaults)
# Uses hand crafted test cases against predicted restults to prove they work!
BEGIN {
my $fish = turn_fish_on_off_for_advanced_config ();
unlink ( $fish );
# Turn fish on ...
DBUG_PUSH ( $fish );
DBUG_ENTER_FUNC ();
DBUG_PRINT ("TEST", "\n%s\n ",
'Performing Advanced::Config::Reader::parse_line() ${var} tests!');
use_ok ( "Advanced::Config::Reader" );
use_ok ( "Advanced::Config::Options" );
DBUG_VOID_RETURN ();
}
END {
DBUG_ENTER_FUNC ();
# Don't do this test per done_testing() logic!
# dbug_ok (1, "In the END block!"); # Last test.
DBUG_VOID_RETURN ();
}
# For overriding the fish mask in parse_line().
my $oTag = "DBUG_TEST_USE_CASE_PARSE_OVERRIDE";
my $opts;
my $assign;
# --------------------------------------
# Start of the main program!
# --------------------------------------
{
DBUG_ENTER_FUNC (@ARGV);
dbug_ok (1, "In the MAIN program ..."); # Test # 3 ...
$opts = get_read_opts ( { $oTag => 1 } );
$assign = convert_to_regexp_string ($opts->{assign});
dbug_ok (1, "-"x60);
parse_tv ("Simple", "There are no comments!", "");
parse_tv ("Simple-2", "Comments are all spaces!", " ");
parse_tv ("Reglar", "Value with Comment", "This is a comment");
parse_tv ("Reglar-2", "I'm going to the park!", "I'll go with you!");
parse_tv ("Reglar-3", "I'm going to the park!", "I'll go \${with} you!");
# The Balanced Quote Tests ...
parse_tv ("Quote-1", "'In the heat of the night'", "I'm at the park!");
parse_tv ("Quote-2", '"In the chill of the day"', '"Killroy" was here!');
# The Unbalanced Quote Tests ...
parse_tv ("Unbalanced-1", "'In the heat of the night", "I'm at the park!");
parse_tv ("Unbalanced-2", '"In the chill of the day', '"Killroy" was here!');
parse_tv ("Unbalanced-3", "In the heat of the night'", "I'm at the park!");
parse_tv ("Unbalanced-4", 'In the chill of the day"', '"Killroy" was here!');
parse_tv ("Messy-1", "'One', 'fine', 'day'", "'Sitting' 'in' 'a' 'tree'");
parse_tv ("Messy-2", '"Two", "by", "Two"', '"Is" "how" "we" "go"');
parse_tv ("Odd-1", "'Once upon a time' Hello!", "Go on!");
parse_tv ("Odd-2", '"Once upon a time" Good Bye!', "Go on!");
# The Variable Replacement Tests ...
parse_tv ("Var-1", 'Help me with ${var1} resolve!', "");
parse_tv ("Var-2", 'Help me with ${var2} resolve!', "A constant");
parse_tv ("Var-3", 'Help me with ${var3} resolve!', 'A ${variable}');
parse_tv ("Var-4", 'Help me with ${var4} & ${var5} resolve!', 'A ${var1} ${var2}');
parse_tv ("Nest-1", 'Eval ${help_${#me}_${please}} ${also#* }', 'Hello');
parse_tv ("Nest-2", 'Eval ${help_${#me}_${please}} ${also#* }', 'Hello ${world}');
parse_tv ("Nest-3", 'Eval ${help_${#me}_${please}} ${also#* }', 'Hello ${world} ${#2}');
( run in 0.857 second using v1.01-cache-2.11-cpan-e1769b4cff6 )