Advanced-Config
view release on metacpan or search on metacpan
t/02-basic_parse_line_02_overrides.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. (overriding some 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!');
# Doesn't expose methods if use_ok2() is used instead!
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 ( { assign => ':=', comment => ':',
variable_left => '$[', variable_right => ']',
quote_left => '<', quote_right => '>',
${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-3", "In the heat of the night>", "I<m at the park!");
parse_tv ("Messy-1", "<One>, <fine>, <day>", "<Sitting> <in> <a> <tree>");
parse_tv ("Odd-1", "<Once upon a time> Hello!", "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]');
# Using the wrong anchors for Variable replacements ...
parse_tv ("Old-1", 'Help me with ${var3} resolve!', 'A ${variable}');
# Testing nested variable substitution ...
parse_tv ("Nest-1", 'Eval $[help_$[me:=to]_$[please]] $[also:-$[ran]]', 'Hello');
parse_tv ("Nest-2", 'Eval $[help_$[me:=to]_$[please]] $[also:-$[ran]]', 'Hello $[world]');
( run in 0.855 second using v1.01-cache-2.11-cpan-e1769b4cff6 )