From: Will Budic Date: Mon, 10 Nov 2025 06:52:00 +0000 (+1100) Subject: upd. to pass with new CNF base package. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=c8c493b338db0b850e582c7ece700de71741a375;p=PerlCNF.git upd. to pass with new CNF base package. --- diff --git a/tests/testCNFConstances.pl b/tests/testCNFConstances.pl index 89b9a76..a01a21b 100644 --- a/tests/testCNFConstances.pl +++ b/tests/testCNFConstances.pl @@ -1,7 +1,7 @@ #!/usr/bin/env perl use warnings; use strict; use Syntax::Keyword::Try; -use lib "system/modules"; +use lib::relative ('.','../system/modules'); require TestManager; @@ -51,12 +51,12 @@ try{ # ### - # Test constances. + # Test constants. ### $test->case("Test mutability."); try{ $cnf->{'$IMMUTABLE'} = "change?"; - $test->failed('Variable should be a constance!'); + $test->failed('Variable should be a constant!'); }catch{ $test->subcase('Passed test is constance.'); } diff --git a/tests/testCNFConstants.pl b/tests/testCNFConstants.pl new file mode 100644 index 0000000..1b27e83 --- /dev/null +++ b/tests/testCNFConstants.pl @@ -0,0 +1,53 @@ +#!/usr/bin/env perl +use warnings; use strict; +use Syntax::Keyword::Try; +use lib::relative ('.','../system/modules'); + +require CNFParser; +require TestManager; +my $test = TestManager -> new($0); +my $cnf; +try{ + + ### + # Test instance creation. + ### + die $test->failed() if not $cnf = CNFParser->new(undef,{MyConstant=>"Can't be changed!"}); + $test->case("Passed new instance CNFParser.",'1'); + $test->subcase('CNFParser->VERSION is '.CNFParser->VERSION); + $test->subcase('Try changing an constant.'); + try{ + $cnf->{MyConstant} = ""; + $test->failed("Constance must not be able to change!"); + }catch{ + $test->passed("Passed not can change!"); + } + $test->subcase('Try finding an constant not existing'); + try{ + $cnf->{EXISTS} = ""; + $test->failed("Constance exists how?"); + }catch{ + $test->passed("Passed constant EXISTS not has been made to exists!"); + } + + + $test-> nextCase(); + $test->case("Import Repository Methods",'2'); + $cnf -> _import_into_this_package(); + try{ + my $val = const('MyConstant'); + $test->isDefined('MyConstant',$val); + $test->evaluate('MyConstant',"Can't be changed!",$val); + + }catch{ + $test->failed("Failed to import methods"); + } + + # + $test->done(); + # +} +catch{ + $test -> dumpTermination($@); + $test -> doneFailed(); +} diff --git a/tests/testCNFParserLogging.pl b/tests/testCNFParserLogging.pl index dce37f3..834a0f8 100644 --- a/tests/testCNFParserLogging.pl +++ b/tests/testCNFParserLogging.pl @@ -1,23 +1,25 @@ #!/usr/bin/env perl use warnings; use strict; use Syntax::Keyword::Try; -#no critic "eval" -use lib "system/modules"; + +use lib::relative ('.','../system/modules'); require CNFParser; require TestManager; my $test = TestManager -> new($0); my $cnf; +my $logfile = 'zzz_temp.log'; + try{ ### # Test instance creation. - # - my $logfile = 'zzz_temp.log'; + # die $test->failed() if not $cnf = CNFParser->new(undef,{DO_ENABLED=>1,DEBUG=>1,'%LOG'=>{enabled=>1,file=>$logfile, tail=>10}}); - $test->case("Passed new instance CNFParser with log setings."); + $test->case("Passed new instance CNFParser with log settings."); + #`rm $logfile` if -f $logfile; - $cnf->log("$_") for (1..20); + $cnf->log("$_") for (1..20);# Last log eleven tail cuts all previous log entries. $cnf->parse(undef,'<<>>'); $test->evaluate('test == this', $cnf->anon('test'),'this'); # @@ -25,7 +27,7 @@ try{ $test->case("Has log only tail last 10 lines?"); open (my $fh, "<", $logfile) or die $!; - my $cnt=11; + my $cnt=11;# <- should tail cut firs line to have 11. while(my $line = <$fh>){ chomp($line); $test -> evaluate("Log $line ends with $cnt?", $cnt, $line =~ m/(\d*)$/); @@ -33,7 +35,7 @@ try{ } close $fh; $test -> evaluate("Is ten lines tailed?", ($cnt-11), 10); - `rm $logfile`; + `rm $logfile` if -f $logfile; # $test->done(); # diff --git a/tests/testCRONSchedular.pl b/tests/testCRONSchedular.pl index 91af1a2..c420106 100644 --- a/tests/testCRONSchedular.pl +++ b/tests/testCRONSchedular.pl @@ -4,7 +4,7 @@ use Syntax::Keyword::Try; use Benchmark; use File::stat; -use lib "system/modules"; +use lib::relative ('.','../system/modules'); require TestManager; require CNFParser; @@ -14,7 +14,7 @@ my $test = TestManager -> new($0); my $cnf; try{ - my $fstat = CNFParser::_fetchScriptStat($0); + my $fstat = CNF::_fetchScriptStat($0); die $test->failed() if not $cnf = CNFParser->new( undef, {DO_ENABLED=>1,'%LOG'=>{console=>1},TZ=>'Australia/Sydney', CNF_STAT => $fstat} ); diff --git a/tests/testExperimental.pl b/tests/testExperimental.pl index 72daa78..930ff0c 100644 --- a/tests/testExperimental.pl +++ b/tests/testExperimental.pl @@ -40,7 +40,7 @@ try{ # $test -> nextCase(); # #### -my $fstat = CNFParser::_fetchScriptStat($0); + my $fstat = CNF::_fetchScriptStat($0); my $CNF_SCRIPT = qq{ diff --git a/tests/testProcessor.pl b/tests/testProcessor.pl index 276d531..f87cb29 100644 --- a/tests/testProcessor.pl +++ b/tests/testProcessor.pl @@ -1,22 +1,20 @@ #!/usr/bin/env perl use warnings; use strict; use Syntax::Keyword::Try; -use lib "system/modules"; +use lib::relative ('.','../system/modules'); require TestManager; -require CNFParser; +require CNFParser; CNFParser::_import_into_this_package(); my $test = TestManager -> new($0); -my $cnf; - -try{ - die $test->failed() if not my $cnf = CNFParser->new(undef,{'%LOG'=>{console=>1}}); +try{ #If STRICT is true parser will throw error, accessing from here. + die $test->failed() if not my $cnf = CNFParser->new(undef,{STRICT=>0,'%LOG'=>{console=>1}}); $test->case('Passed CNFParser->new().'); $test->case("Parse Typical Processor registration."); my $processor = $cnf->registerProcessor("TestInstructor",'process'); $test->isDefined("\$processor", $processor); - $test -> nextCase(); + $test -> nextCase(); $test->case("Test parsing registration."); $cnf->parse(undef,q( <function:process>> diff --git a/tests/testSQL.pl b/tests/testSQL.pl index 95c2a48..6f540d7 100644 --- a/tests/testSQL.pl +++ b/tests/testSQL.pl @@ -56,7 +56,7 @@ try{ # my $plugin = $cnf->property('PROCESS_RSS_FEEDS'); # $test->failed() if not $plugin; - # if(CNFParser::_isTrue($plugin->{CONVERT_TO_CNF_NODES})){ + # if(CNF::_isTrue($plugin->{CONVERT_TO_CNF_NODES})){ # $test->subcase('Test data to CNF nodes tree conversion for RSS feeds.'); # my $perl_weekly = $cnf->getTree('Perl Weekly'); # $test->isDefined("Has tree 'Perl Weekly'?",$perl_weekly); diff --git a/tests/testSQLPostgres_on_elite.pl b/tests/testSQLPostgres_on_elite.pl index aa037bc..c15e8d7 100644 --- a/tests/testSQLPostgres_on_elite.pl +++ b/tests/testSQLPostgres_on_elite.pl @@ -1,9 +1,10 @@ #!/usr/bin/env perl -use 5.28.0; -use warnings; use strict; +use warnings; +use strict; +use feature "say"; use Syntax::Keyword::Try; use Benchmark; -use lib 'system/modules'; +use lib::relative ( '.', '../system/modules' ); require TestManager; require CNFParser; @@ -27,7 +28,9 @@ my $DB_SETTINGS = q( try{ - die $test->failed() if not $cnf = CNFParser->new(undef,{'%LOG'=>{console=>1}}); +die $test->failed() + if not $cnf = + CNFParser->new( undef, { STRICT => 0, '%LOG' => { console => 1 } } ); $test->case("Passed new instance CNFParser."); $test->case("Test Obtaining localProjectConfigFile."); @@ -36,7 +39,8 @@ try{ print "Obtained path: $path\n"; $test->subcase("Test as projected path."); - $path = CNFParser->new(undef,{PROJECT_NAME=>'MY_PROJECT'}) -> localProjectConfigFile(); +$path = CNFParser->new( undef, { STRICT => 0, PROJECT_NAME => 'MY_PROJECT' } ) + ->localProjectConfigFile(); print "Obtained path: $path\n"; # diff --git a/tests/test_DATA_Instruction.pl b/tests/test_DATA_Instruction.pl index 9e394f8..59d4b4d 100644 --- a/tests/test_DATA_Instruction.pl +++ b/tests/test_DATA_Instruction.pl @@ -65,7 +65,7 @@ owned by Disney.), $array[0][2]); $test-> nextCase(); # $test->case("Is DATA reserved word."); - $test->isDefined("isReservedWord('DATA')",1,$cnf->isReservedWord("DATA")); + $test->evaluate("isReservedWord('DATA')",1,$cnf->isReservedWord("DATA")); ### # $test->done();