view release on metacpan or search on metacpan
t/02-basic_parse_line_02_overrides.t view on Meta::CPAN
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 {
t/02-basic_parse_line_02_overrides.t view on Meta::CPAN
# --------------------------------------
# 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]');
parse_tv ("Nest-3", 'Eval $[help_$[me:=to]_$[please]] $[also:-$[ran]]', 'Hello $[world] $[2:-$[3]]');
parse_tv ("Nest-4", 'Eval $[help_$[me:=to]_$[please]] $[also:-$[ran]]', 'Hello $[world] $[2#* ]');
# Corrupted Variable definitions ...
parse_tv ("Var-Unbal-0", 'Want to $[ $[help_$[me:=to]_$[please]] $[also#* ]', 'Static Comment');
parse_tv ("Var-Unbal-1", 'Want to $[ $[help_$[me:=to]_$[please]] $[also#* ]', 'Hello $[ $[world] $[2:-$[3]]');
parse_tv ("Var-Unbal-2", 'Want to $[help_$[me:=to]_$[please]] $[also#* ] $[', 'Hello $[world] $[2:-$[3]] $[');
parse_tv ("Var-Unbal-3", 'Want to $[help_$[me:=to]_$[please]] $[ ${also#* ]', 'Hello $[world] $[ ${2:-$[3]]');
parse_tv ("Var-Unbal-4", 'Ending ] $[help_$[#me]_$[please]] $[also#* ]', 'Hello ] $[world] $[2:-$[3]]');
parse_tv ("Var-Unbal-5", 'Ending $[help_$[me:=to]_$[please]] $[also#* ] ]', 'Hello $[world] $[2:-$[3]] ]');
parse_tv ("Var-Unbal-6", 'Ending $[help_$[me:=to]_$[please]] ] $[also#* ]', 'Hello $[world] } $[2:-$[3]]');
parse_tv ("Var-Unbal-7", 'Ending $[help_$[me:=to]_$[please]] ] $[also#* ]', 'Static Comment');
# Missing Variable definitions ...
parse_tv ("Missing-1", 'Help $[] me', 'Please! $[].');
parse_tv ("Missing-2", 'Help $[ ] again', 'Or Not! $[ ].');
parse_tv ("Missing-3", 'Help $[] again and $[ :=again]', 'Or Not! $[ ].');
# Since I didn't count the test cases, must end my program
# with a call to this method. After this we can't put any
# tests in the END block!
done_testing ();
DBUG_LEAVE (0);
}
# -----------------------------------------------
t/27-disable_decrypt_test.t view on Meta::CPAN
test_tag ($cfg1, "test1", 0, 0, 0);
test_tag ($cfg1, "test2", 0, 1, 1); # An encrypted value.
test_tag ($cfg1, "test3", 1, 0, 1);
test_tag ($cfg1, "test4", 1, 0, 1);
test_tag ($cfg1, "test5", 0, 0, 1); # The problem test ...
test_tag ($cfg1, "test6", 1, 0, 1);
test_tag ($cfg1, "test7", 1, 0, 1);
my $lbl = "test999";
my $val = test_tag ($cfg1, $lbl, 1, 0, 1);
my @parts = split (qr/\$[{]/, $val);
# foreach ( @parts ) { print STDERR "----> $_\n"; }
my $cnt = @parts; --$cnt;
my $total_vars = 6;
dbug_is ($total_vars, $cnt, "Tag ${lbl} has ${cnt} variables in it! (Expect ${total_vars})");
dbug_ok (1, "===========================================");
$val = test_tag ($cfg3, $lbl, 1, 0, 0);
@parts = split (qr/\$[{]/, $val);
$cnt = @parts; --$cnt;
$total_vars = 13;
dbug_is ($cnt, $total_vars, "Tag ${lbl} has ${cnt} variables in it! (Expect ${total_vars})");
done_testing ();
DBUG_LEAVE (0);
}
t/config/30-alt_symbol_control.cfg view on Meta::CPAN
# Test against itself ...
[ 10-simple.cfg ]
croak = 2 # Call die if it doesn't parse correctly.
# ---------------------------------------------------------------------
[ 30-alt_symbols_01.cfg ]
assign = ==
comment = :
variable_left = '$[' # $[..] for variable substitution
variable_right = ']'
quote_left = '^' # ^..^ for balanced quotes
quote_right = '^'
croak = 2 # Call die if it doesn't parse correctly.
# ---------------------------------------------------------------------
[ 30-alt_symbols_02.cfg ]
assign = ==
comment = =
t/config/30-alt_symbol_control.cfg view on Meta::CPAN
variable_right = '%'
quote_left = '<' # <..> for balanced quotes
quote_right = '>'
croak = 2
# ---------------------------------------------------------------------
[ 30-alt_symbols_03.cfg ]
assign = :=
comment = ?
variable_left = '$[' # $[..] for variable substitution
variable_right = ']'
quote_left = '@' # @..@ for balanced quotes ...
quote_right = '@'
croak = 2
# Defines the tag to look up in the config file for the section name to use.
section_test_01 = section_03
# ---------------------------------------------------------------------
t/config/30-alt_symbol_control.cfg view on Meta::CPAN
croak = 2
section_test_01 = section_01
section_test_02 = section_02
# ---------------------------------------------------------------------
[ 30-alt_symbols_05 space assign.cfg ]
assign = \s # Special case of space separated tag/values
comment = :
variable_left = '$[' # $[..] for variable substitution
variable_right = ']'
quote_left = '^' # ^..^ for balanced quotes
quote_right = '^'
croak = 2 # Call die if it doesn't parse correctly.
# =====================================================================
[ 30-alt_symbols_70 merge multiple files.cfg ]
source_cb = "main::ALTER_SOURCE_CALLBACK_OPTIONS"
croak = 2
t/config/30-alt_symbols_01.cfg view on Meta::CPAN
: It's validated by t/30-alt_symbols_cfg.t
:
: Any changes made to this config file should also be refleced
: in: t/config/10-simple.cfg
: That config file is used to validate this one!
:
: --------------------------------------------------------------
: The required substitutions ...
: Assignment (=) ==> ==
: Comments (#) ==> :
: Variables (${..}) ==> $[..]
: Quotes (' or ") ==> ^..^
: --------------------------------------------------------------
a == ^A is for Apple!^
b == B is for Bat! : A comment
c==^C is for Cat!^ : Another comment
t/config/30-alt_symbols_01.cfg view on Meta::CPAN
h_pwd == ^Hello World!^ : Should^t appear in fish.
: --------------------------------------------------------------
one == ONE
two == TWO
three == THREE
: All 3 evaluate to the same value ...
number 1 == ^$[one] $[two] $[three]^
number 2 == ^$[one] $[two] $[three]^
number 3 == $[one] $[two] $[three]
: All 3 evaluate to the same value again ...
number 6 == ^$[one] $[two] $[three]^ : A comment ...
number 5 == ^$[one] $[two] $[three]^ : A comment ...
number 4 == $[one] $[two] $[three] : A comment ...
number 8 == $[number 1]
rule8 missing == $[undefined] : Returns ^^ as it^s value.
: Testing the special variables ... (Rule 0)
shft3 == ^zzzzzzzzz^ : Line should be ignored!
cmt == $[shft3]
cmt2 == $[shft33]
cmt3 == $[shft333]
: Look up these 3 special perl variables ... (Rule 5)
rule5_pid == $[$] : Different per test ...
rule5_prog == $[0]
rule5_os == $[^O]
: Look up these special variables ... (Rule 6)
rule6_host == $[hostname]
rule6_user == $[user]
rule6_pid == $[PID] : Should match $[rule5_pid]
rule6_ppid == $[PPID] : Different per test ...
rule6_p == $[program]
rule6_sep == $[sep] : Varies by OS
: Here are some dates we are interested in!
: The date keywords use rule 7 ... So mixes rule 6 & 7.
log1 == t$[sep]logs$[sep]$[program].$[today].txt
log2 == t$[sep]logs$[sep]$[program].$[yesterday].txt
log3 == t$[sep]logs$[sep]$[program].$[tomorrow].txt
: Here are some strange variables to see what happens!
empty_1 == $[]
empty_2 == $[ ]
empty_3 == abc $[] xyz
empty_4 == abc $[ ] xyz
t/config/30-alt_symbols_03.cfg view on Meta::CPAN
? It's validated by t/30-alt_symbols_cfg.t
?
? Any changes made to this config file should also be refleced
? in: t/config/10-simple.cfg
? That config file is used to validate this one!
?
? --------------------------------------------------------------
? The required substitutions ...
? Assignment (=) ==> :=
? Comments (#) ==> ?
? Variables (${..}) ==> $[..]
? Quotes (' or ") ==> @..@
? --------------------------------------------------------------
section_03 := This is a long section name!
section_04 := This is an empty section!
[ $[section_04] ]
[ $[section_03] ]
a := @A is for Apple!@
b := B is for Bat! ? A comment
c:=@C is for Cat!@ ? Another comment
? Another comment ...
d :=D is for Dog! ? Comment (????) ...
t/config/30-alt_symbols_03.cfg view on Meta::CPAN
h_pwd := @Hello World!@ ? Should@t appear in fish.
? --------------------------------------------------------------
one := ONE
two := TWO
three := THREE
? All 3 evaluate to the same value ...
number 1 := @$[one] $[two] $[three]@
number 2 := @$[one] $[two] $[three]@
number 3 := $[one] $[two] $[three]
? All 3 evaluate to the same value again ...
number 6 := @$[one] $[two] $[three]@ ? A comment ...
number 5 := @$[one] $[two] $[three]@ ? A comment ...
number 4 := $[one] $[two] $[three] ? A comment ...
number 8 := $[number 1]
rule8 missing := $[undefined] ? Returns @@ as it@s value.
? Testing the special variables ... (Rule 0)
shft3 := @zzzzzzzzz@ ? Line should be ignored!
cmt := $[shft3]
cmt2 := $[shft33]
cmt3 := $[shft333]
? Look up these 3 special perl variables ... (Rule 5)
rule5_pid := $[$] ? Different per test ...
rule5_prog := $[0]
rule5_os := $[^O]
? Look up these special variables ... (Rule 6)
rule6_host := $[hostname]
rule6_user := $[user]
rule6_pid := $[PID] ? Should match $[rule5_pid]
rule6_ppid := $[PPID] ? Different per test ...
rule6_p := $[program]
rule6_sep := $[sep] ? Varies by OS
? Here are some dates we are interested in!
? The date keywords use rule 7 ... So mixes rule 6 & 7.
log1 := t$[sep]logs$[sep]$[program].$[today].txt
log2 := t$[sep]logs$[sep]$[program].$[yesterday].txt
log3 := t$[sep]logs$[sep]$[program].$[tomorrow].txt
? Here are some strange variables to see what happens!
empty_1 := $[]
empty_2 := $[ ]
empty_3 := abc $[] xyz
empty_4 := abc $[ ] xyz
t/config/30-alt_symbols_05 space assign.cfg view on Meta::CPAN
: It's validated by t/30-alt_symbols_cfg.t
:
: Any changes made to this config file should also be refleced
: in: t/config/10-simple.cfg
: That config file is used to validate this one!
:
: --------------------------------------------------------------
: The required substitutions ...
: Assignment (=) ==> \\s
: Comments (#) ==> :
: Variables (${..}) ==> $[..]
: Quotes (' or ") ==> ^..^
: --------------------------------------------------------------
: This one's very ugly with no assignment operator being used!
: --------------------------------------------------------------
a ^A is for Apple!^
b B is for Bat! : A comment
t/config/30-alt_symbols_05 space assign.cfg view on Meta::CPAN
h_pwd ^Hello World!^ : Should^t appear in fish.
: --------------------------------------------------------------
one ONE
two TWO
three THREE
: All 3 evaluate to the same value ...
number=1 ^$[one] $[two] $[three]^
number=2 ^$[one] $[two] $[three]^
number=3 $[one] $[two] $[three]
: All 3 evaluate to the same value again ...
number=6 ^$[one] $[two] $[three]^ : A comment ...
number=5 ^$[one] $[two] $[three]^ : A comment ...
number=4 $[one] $[two] $[three] : A comment ...
number=8 $[number=1]
rule8=missing $[undefined] : Returns ^^ as it^s value.
: Testing the special variables ... (Rule 0)
shft3 ^zzzzzzzzz^ : Line should be ignored!
cmt $[shft3]
cmt2 $[shft33]
cmt3 $[shft333]
: Look up these 3 special perl variables ... (Rule 5)
rule5_pid $[$] : Different per test ...
rule5_prog $[0]
rule5_os $[^O]
: Look up these special variables ... (Rule 6)
rule6_host $[hostname]
rule6_user $[user]
rule6_pid $[PID] : Should match $[rule5_pid]
rule6_ppid $[PPID] : Different per test ...
rule6_p $[program]
rule6_sep $[sep] : Varies by OS
: Here are some dates we are interested in!
: The date keywords use rule 7 ... So mixes rule 6 & 7.
log1 t$[sep]logs$[sep]$[program].$[today].txt
log2 t$[sep]logs$[sep]$[program].$[yesterday].txt
log3 t$[sep]logs$[sep]$[program].$[tomorrow].txt
: Here are some strange variables to see what happens!
empty_1 $[]
empty_2 $[ ]
empty_3 abc $[] xyz
empty_4 abc $[ ] xyz