]> lifelog.hopto.org Git - PerlCNF.git/commitdiff
upd. to pass with new CNF base package.
authorWill Budic <redacted>
Mon, 10 Nov 2025 06:52:00 +0000 (17:52 +1100)
committerWill Budic <redacted>
Mon, 10 Nov 2025 06:52:00 +0000 (17:52 +1100)
tests/testCNFConstances.pl
tests/testCNFConstants.pl [new file with mode: 0644]
tests/testCNFParserLogging.pl
tests/testCRONSchedular.pl
tests/testExperimental.pl
tests/testProcessor.pl
tests/testSQL.pl
tests/testSQLPostgres_on_elite.pl
tests/test_DATA_Instruction.pl

index 89b9a7639ed9ddbdbd6c85de672c9c2b069cc763..a01a21b9cb1ac3a035934396f73d7e535000767c 100644 (file)
@@ -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 (file)
index 0000000..1b27e83
--- /dev/null
@@ -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();
+}
index dce37f3fbbc792abba86d086417109414bb1e176..834a0f8bba05a3de47f2895f70675e46b684d835 100644 (file)
@@ -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 this>>>');
     $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();
     #
index 91af1a26663d951c870306207bdeef671188f09c..c4201065eda388da01c590daa6b163915d535721 100644 (file)
@@ -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}
             );
index 72daa78f92c899c6f18594c9f450b9e0990f6d41..930ff0c3f45f88a8431954d1458cd0db2fffbf88 100644 (file)
@@ -40,7 +40,7 @@ try{
 #    $test -> nextCase();
 #    ####
 
-my $fstat = CNFParser::_fetchScriptStat($0);
+   my $fstat = CNF::_fetchScriptStat($0);
 
    my $CNF_SCRIPT = qq{
 
index 276d53165280cc196dbe2a99614812b5dbd96f25..f87cb290fe7dfe3b197cb40590453b0de2d136d8 100644 (file)
@@ -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(
             <<TestInstructor<PROCESSOR>function:process>>
index 95c2a485f45fcd30175e7ae00e0ac7834f3625d2..6f540d7ce2cdbd934b72634ec6b13b98dbd6b25b 100644 (file)
@@ -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);
index aa037bca29dd85a15f0f45a85126f4b49022ced1..c15e8d7335cd818821f1a477d1ca724a3f35e575 100644 (file)
@@ -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";
 
    #
index 9e394f819b7e881daa5ecb5edc35c5480a48372e..59d4b4d745db23f6009ee57910683a1df85d3f9c 100644 (file)
@@ -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();