</html>
|;
my $dom = Mojo::DOM->new($content);
-print $dom->find('tr[class="balls"] td')->map('text')->join(","),"\n";
-$dom->find('tr[class="balls"] td')->last->append('<td>4</td>');
+print $dom->search('tr[class="balls"] td')->map('text')->join(","),"\n";
+$dom->search('tr[class="balls"] td')->last->append('<td>4</td>');
print $dom;
}
sub case {
- my ($self, $out) =@_;
- my ($package, $filename, $line) = caller; $filename =~ s/^(\/(.+)\/)//gs;
+ my ($self, $out, $ref) =@_;
+ my ($package, $filename, $line) = caller; $filename =~ s/^(\/(.+)\/)//gs;
+ die "Case REF not in ordinal string format!\n For -> $CWD/$filename:$line\n" if $ref && $ref !~ m/\d*/g;
$stab="";
nextCase($self) if $self->{open};
print BRIGHT_CYAN,"\tCase ".$self->{test_cnt}.": $out", BLUE, "\n\tat -> ",
if(@_== 3 && $cc eq 'test-is-undef'){
my $swp = $aa; $aa = $bb; $bb = $cc; $cc = $swp
}
+ $aa="" if !$aa; $bb="" if !$bb; $cc="" if !$cc;
my ($package, $filename, $line) = caller; $filename =~ s/^(\.\/.*\/)/\@/;
print BLINK. BRIGHT_RED."\t$stab Test ".$self->{test_cnt} .'.'. ++$self->{sub_cnt}.
- ": Failed! (". $self->{sub_err} .")",RESET, YELLOW, " $filename line $line\n",
+ ": Failed! (". $self->{sub_err} .")",RESET, YELLOW, " $filename:$line\n",
BRIGHT_RED,"[$cc].eval(-> \$a->$aa, \$b->$bb <-)\n",RESET;
return 0;
}
# @return 1 on evaluation passed, 0 on failed.
###
sub isDefined{
- my ($self, $var, $val)=@_;
- die "The expected parameters required failed TestManager->isDefined($var,$val)!" if @_ < 3;
+ my ($self, $var, $val)=@_;
+ my ($package, $filename, $line) = caller;
+ die qq( The expected parameters count required
+ failed on TestManager->isDefined(\$var:"$var",\$val:"$val")!
+ \@Test -> $filename:$line
+ )
+ if @_ < 2;
my $ref = ref($val);
if (defined $val||$ref){
print GREEN."\t$stab YDef ".$self->{test_cnt} .'.'. ++$self->{sub_cnt}.": Passed -> Scalar [$var] is defined.\n"
}
sub isZeroOrEqual{
- my ($self, $var, $aa, $bb)=@_;
- if ($aa == 0 or $aa==$bb){
+ my ($self, $var, $aa, $bb)=@_;$bb =0 if !$bb; $aa = 0 if !$aa ;
+ if ($aa or $aa==$bb){
print GREEN."\t$stab YDef ".$self->{test_cnt} .'.'. ++$self->{sub_cnt}.": Passed -> Scalar [$var] is ZeroOrEqual.\n"
}else{
++$self->{sub_err};
- print BLINK. BRIGHT_RED."\t$stab YDef ".$self->{test_cnt} .'.'. ++$self->{sub_cnt}. ": Failed!"." ($self->{sub_err}) ".RESET. RED."Scalar [$var] is not equal!\n";
+ print BLINK. BRIGHT_RED."\t$stab YDef ".$self->{test_cnt} .'.'. ++$self->{sub_cnt}. ": Failed!"." ($self->{sub_err}) ".RESET. RED."Scalar [$var] is not ZeroOrEqual!\n";
return 0;
}
return 1;
###
# Performs non critical evaluation if an scalar is undefined.
-# Atributes are $var for variable name and, $val the actual variable.
+# Attributes are $var for variable name and, $val the actual variable.
# @return 1 on evaluation passed, 0 on failed.
###
sub isNotDefined{
print GREEN."\t$stab NDef ".$self->{test_cnt} .'.'. ++$self->{sub_cnt}.": Passed -> Scalar [$var] is not defined.\n"
}else{
++$self->{sub_err};
- print BLINK. BRIGHT_RED."\t$stab NDef ".$self->{test_cnt} .'.'. ++$self->{sub_cnt}. ": Failed!"." ($self->{sub_err}) ".RESET. RED."Scalar [$var] is defined!\n";
+ print BLINK. BRIGHT_RED."\t$stab NDef ".$self->{test_cnt} .'.'. ++$self->{sub_cnt}. ": Failed!"." ($self->{sub_err}) ".RESET. RED."Scalar [$var] expected NOT but is defined!\n";
return 0;
}
return 1;
sub frmln { my($at)=@_;
return sprintf($DEC,$at)
}
-1;
-=begin copyright
-Programed by : Will Budić
-EContactHash : 990MWWLWM8C2MI8K (https://github.com/wBudić/EContactHash.md)
-Source : https://github.com/wBudić/PerlCNF.git
-Documentation : Specifications_For_CNF_ReadMe.md
- This source file is copied and usually placed in a local directory, outside of its repository project.
- So it could not be the actual or current version, can vary or has been modified for what ever purpose in another project.
- Please leave source of origin in this file for future references.
-Open Source Code License -> https://github.com/wBudić/PerlCNF/blob/master/ISC_License.md
-=cut copyright
+1;
###
-# To debug in vscode you need the extension LanguageServer and Debuger by Gerald Richter
+# To debug in vscode you need the extension LanguageServer and Debugger by Gerald Richter
# the optional Perl Navigator uses also the LanguagerServer but isn't one.
# To debug in vs code the local use lib ... have to be commented out.
# Do not forget to uncoment them when commiting or using outside of vscode.
# requires full paths for Gerald's extension because it is dumb to reslove this.
#
# "perl.perlInc": [
-# "/home/will/dev_new/PerlCNF/tests",
-# "/home/will/dev_new/PerlCNF/system/modules"
+# "tests",
+# "system/modules"
# ]
#
-###
\ No newline at end of file
+###
+
+=begin copyright
+Programed by : Will Budić
+EContactHash : 990MWWLWM8C2MI8K (https://github.com/wBudić/EContactHash.md)
+Source : https://github.com/wBudić/PerlCNF.git
+Documentation : Specifications_For_CNF_ReadMe.md
+ This source file is copied and usually placed in a local directory, outside of its repository project.
+ So it could not be the actual or current version, can vary or has been modified for what ever purpose in another project.
+ Please leave source of origin in this file for future references.
+Open Source Code License -> https://github.com/wBudić/PerlCNF/blob/master/ISC_License.md
+=cut copyright
\ No newline at end of file
# requires full paths for Gerald's extension because it is dumb to reslove this.
#
# "perl.perlInc": [
-# "/home/will/dev_new/PerlCNF/tests",
-# "/home/will/dev_new/PerlCNF/system/modules"
+# "tests",
+# "system/modules"
# ]
# After that disable all the followin use lib ... statements:
###
# Test instance creation.
###
die $test->failed() if not $cnf = CNFParser->new();
- $test->case("Passed new instance CNFParser.");
+ $test->case("Passed new instance CNFParser.",'1');
$test->subcase('CNFParser->VERSION is '.CNFParser->VERSION);
${$cnf->anon()}{Public} = 'yes';
$test->evaluate('$cnf->anon(Public) == "yes"',$cnf->anon('Public'),'yes');
- $test->evaluate('$new->anon(Exclusive) == "yes"', CNFParser->new()->anon('Public'),'yes');
+ $test->evaluate('$new->anon(Public) == "yes"', CNFParser->new()->anon('Public'),'yes');
#
$test-> nextCase();
#
# Test private instance config.
###
my $private = CNFParser->new(undef,{Exclusive=>'yes', ANONS_ARE_PUBLIC=>0});
- $test->case("Test new private CNFParser.");
+ $test->case("Test new private CNFParser.",'2');
$test->evaluate('$private->{Exclusive} is string "yes"?', $private->{Exclusive},'yes');
$test->evaluate('$private->anon(Exclusive)?', $private->anon('Exclusive'),undef);
- $test->evaluate('$cnf->{Public} is still string "no"?', $cnf->anon('Public'),'yes');
- $test->evaluate('$private->{Public}', $private->anon('Public'),undef);
+ $test->evaluate('$cnf->{Public} is still string "yes"?', 'yes',$cnf->anon('Public'));
+ $test->isZeroOrEqual('$private->anon(Public)', $private->anon('Public'));
# Not defined as it isn't coming from an config file.
- $test->evaluate('Check $private->anon("Exlusive") is undef?', $private->anon("Exclusive"),undef);
+ $test->evaluate('Check $private->anon("Exclusive") is undef?', $private->anon("Exclusive"),undef);
$private->parse(undef,qq/<<test<best>>>/);
$test->evaluate('Check $private->anon("test") is "best"?', $private->anon("test"),'best');
$test->evaluate('Check $cnf->anon("test") is undef?', $cnf->anon("test"),undef);
my $newInstance =CNFParser->new();
$test->evaluate('Check $newInstance->anon("Exclusive") == $cnf->anon("Exclusive")?', $newInstance->anon("Exclusive"), $private->anon("Exclusive"));
${$private->anon()}{Exclusive2} = 'yes';
- $test->case("Passed new private instance CNFParser.");
+ $test->passed("Passed new private instance of CNFParser.");
#
- $test-> nextCase();
+ $test-> nextCase();
#
#CNFParser->new()->parse(undef,q(<<GET_SUB_URL<https://www.$$$1$$$.acme.com/$$$2$$$>>>));
die $test->failed() if keys %$anons == 0;
my %h = %$anons;
my $out; $out.="$_ => $$anons{$_}" for (keys %$anons);
- $test->case("Obtained \%anons{$out}");
+ $test->case("Obtained \%anons{$out}",'3');
#
$test-> nextCase();
#
###
# List entry with non word instructions.
###
- CNFParser->new()->parse(undef,q(<<list$$<20.05$>Spend in supermarket.>>));
- #
+ $test->case("List entry with non word instructions.",'4');
+ my $list_parser = CNFParser->new()->parse(undef,q(<<list$$<20.05$>Spend in supermarket.>>));
+ my @list = $list_parser -> list('list');
+ my $instruction = $list[0];
+ $test -> isDefined("\$instruction", $instruction);
+ $test -> evaluate('$instruction.ins == "20.05$"','20.05$',$instruction->{ins});
+ $test -> evaluate('$instruction.val == "Spend in supermarket."','Spend in supermarket.',$instruction->{val});
+ #
$test-> nextCase();
#
die $test->failed() if $cnf->anon('The Added Two') ne $cnf2->anon('The Added Two');
$test->case("Contains shared 'The Added Two' ->$added");
$test->subcase(CNFParser::anon('The Added One'));
+ $test -> evaluate('CNFParser::anon(The Added One) == "Dynamically!"',CNFParser::anon('The Added One'),'Dynamically!');
#
$test-> nextCase();
###
# Test instance creation.
###
+ $test->case("Test CNFNode instance creation.",'1');
die $test->failed() if not my $node = CNFNode->new({'_'=>'node','#'=>1, DEBUG=>1});
- $test->evaluate("name==node",$node->name(),'node');
- $test->evaluate("val==1",$node->val(),1);
- $test->case("Passed new instance for CNFParser.");
+ $test->passed("Passed new instance for CNFNode.");
+ $test->evaluate("name==node",$node->name(),'node');
+ $test->evaluate("val==1",$node->val(),1);
+
+ #
+ #
+ $test-> nextCase();
#
+ $test->case("TestComplex Shortife Format.",'2');
+
+ $node -> process( CNFParser->new(),q(
+ ___IN_SHORTIFE__ meta __\
+ @@ __\
+ A __\
+ sub1 __\
+ attr1 = Hello
+ a2 : World
+ __//
+ B __\
+ sub2 __\
+Contains this paragraph,
+which is nice.
+ ___///
+ @@ __\
+ tag: css_style
+ property: <*<MarkdownPlugin::CSS>*>
+ __//
+));
+
+ my $list = $node->search('meta/@@');
+ $test -> evaluate("\@list =\ $node->find('meta/@@')", 2,scalar(@$list));
+ #my $sub =
#
$test-> nextCase();
#
+ $test->case("TestComplex Shortife Format Two, proper closing.",'3');
- $test->case("Test deep nested.");
+ $node -> process( CNFParser->new(),q(
+ ___IN_SHORTIFE__ meta2 __\
+ @@ __\
+ A __\
+ sub1 __\
+ attr1 = Hello2
+ a2 : World2 __~
+ __/ #sub1
+ __/
+ B __\
+ sub2 __\
+Contains this paragraph,
+which is nice.
+Giving no advice. __~
+ __/ #sub2
+ __/ #B
+ __/ # @@
+ @@ __\
+ tag: css_style
+ property: <*<MarkdownPlugin::CSS>*>
+ __/
+));
+ my $list2 = $node->search('meta2/@@');
+ $test -> evaluate("\@list2 =\$node->find('meta2/@@')", 2,scalar(@$list2));
+ #
+ $test-> nextCase();
+ #
+ $test->case("TestComplex Shortife Format.",'4');
+
+ $test->case("Test deep nested.",'5');
my $errors = $node -> validate(qq(
[a[
[b[
###
# Test validation.
###
- $test->case("Testing validation.");
+ $test->case("Testing validation.",'6');
- $test->subcase('Misclosed property.');
+ $test->subcase('Missclosed property.');
$errors = $node -> validate(qq(
[a[
$test -> nextCase();
#
- $test -> case("Test when tree script is collapsed.");
+ $test -> case("Test when tree script is collapsed.",'7');
$node -> process( CNFParser->new(),q(
<Example< __IN_SHORTIFE________
Paths __\
$test -> isDefined("$node->node('Example')",$node->node('Example'));
$test -> evaluate("Do we have the Example node?", 'Example', $node->node('Example')->name());
$test -> subcase("Check for a node path.");
- my $search = $node->find('Example/Paths/Attr1');
+ my $search = $node->search('Example/Paths/Attr1');
$test -> isDefined("\$search",$search);
$test -> evaluate("\$search", 'Hey! Let\'s Test. Is it corrupt, in da west?', $search);
$test -> nextCase();
#
- $test -> case("CNFNode to script.");
+ $test -> case("CNFNode to script.",'8');
print $node -> toScript(),"\n";
#
$test -> nextCase();
#
- $test -> case("Find path test for selecting children by certain name.");
+ $test -> case("Find path test for selecting children by certain name.",'9');
- $node -> process( CNFParser->new(),q(
+ $node -> process( CNFParser->new(),q(
<parent<
[has_div_children[
<div<
>parent>
));
- my $find = $node->find('/parent/has_div_children/@$');
- $test -> isDefined("\@find[/parent/has_div_children/@@]",$find);
- $test -> evaluate("\$find[0]"," One ",$find->[0]->val());
- $test -> evaluate("\$find[0]"," Two ",$find->[1]->val());
- $test -> evaluate("\$find[0]","Three",$find->[2]->val());
- $test -> evaluate("\$find[0]"," Four ",$find->[3]->val());
+ $test->subcase("Test contents of nodes via search.");
+
+ my $found = $node->search('/node/parent/has_div_children/@$');
+ $test -> isDefined ('@find[/parent/has_div_children/@$]',$found);
+ $test -> evaluate("\$found[0]"," One ",$found->[0]->val());
+ $test -> evaluate("\$found[0]"," Two ",$found->[1]->val());
+ $test -> evaluate("\$found[0]","Three",$found->[2]->val());
+ $test -> evaluate("\$found[0]"," Four ",$found->[3]->val());
- $find = $node->find('/parent/div/*/text');
- $test -> isZeroOrEqual("\$find",CNFNode::_isNode($find));
- foreach(@$find){
+ $found = $node->search('/node//parent/div/*/text');
+ $test -> isZeroOrEqual("$found",CNFNode::_isNode($found));
+ foreach(@$found){
my $path = $_->toPath();
say "<<$path<", $_->val(),">>>";
- $test -> failed("Path:$path not recognise!")
+ $test -> failed("Path:$path not recognize!")
if $path ne 'node/parent/div/div/div/text' &
$path ne 'node/parent/div/div/div/div/div/text'
}
- $test -> evaluate("\$find[/parent/div/*/text]","Deeply Nested!",$find->[0]->val());
- $test -> evaluate("\$find[/parent/div/*/text]","This Too!",$find->[1]->val());
+ $test -> evaluate("\$found[/parent/div/*/text]","Deeply Nested!",$found->[0]->val());
+ $test -> evaluate("\$found[/parent/div/*/text]","This Too!",$found->[1]->val());
- my $find2 = $node->find('/parent/*/text');
+ my $found2 = $node->search('/parent/*/text');
$test -> subcase("Select all text nodes in parent.")->
- evaluate("\$find2[/parent/*/text]",3,scalar @$find2);
- $test -> evaluate("\$find2[/parent/*/text]",'Shallow', $find2->[2]->val());
+ evaluate("\$found2[/parent/*/text]",3,scalar @$found2);
+ $test -> evaluate("\$found2[/parent/*/text]",'Shallow', $found2->[2]->val());
$test -> subcase("Find and return value of attribute.");
- my $find3 = $node->find('/parent/attribute');
- $test -> evaluate("[/parent/attribute]",'attribute value', $find3);
+ my $found3 = $node->search('/parent/attribute');
+ $test -> evaluate("[/parent/attribute]",'attribute value', $found3);
#
$test -> nextCase();
my $test = TestManager->new($0);
package Constants;
-#<- Global Typeglob declared creates
-# read only references but these are NOT constants.
+# Global Typeglob declared creates
+# read only references but these are NOT constants.
*GlobelTroter = \"TEST";
package main;
use Syntax::Keyword::Try; try {
+
+ $test -> case("Test process list parsing shortif directly.", '1' );
+
+ $test -> subcase("Multiline value.");
+ my $nd1 = CNFNode::_createNode('root');
+ CNFNode::_parseShortife( \$nd1, q(
+ A __\
+ sub __\
+Contains this paragraph,
+which is nice.
+Giving no advice.
+__~
+ __/
+ __/
+ ));
+ my $a_sub = $nd1->node('A/sub/');
+ $test->isDefined("has A/sub?",$a_sub);
+ $test ->evaluate("value of A/sub?.",
+q(Contains this paragraph,
+which is nice.
+Giving no advice.
+),$a_sub->val());
+
+
+ my $parse_listed = CNFParser-> new() -> parse(undef,q(<<<TREE __IN_SHORTIFE__
+ listed _____\
+ @@ __\
+ 1 2 3
+ __/
+
+ @@ __\
+ 2
+ __/
+ __/
+ >>>));
+ $test->isDefined("CNF sequential anon format 'listed' is defined?",$parse_listed->anon('listed'));
+ $parse_listed = $parse_listed->anon('listed');
+ $test->evaluate("CNF sequential anon format 'listed' has two itens?",2,scalar(@{$parse_listed->list()}));
+
+
+ $test -> case("Test process shortif directly with CNF sequential anon format.", '2');
+ my $parsing = CNFParser-> new() -> parse(undef,q(<<<TREE __IN_SHORTIFE__ node __\
+ __/>>>));
+ $test->isDefined("CNF sequential anon format node is defined?",$parsing->anon('node'));
+
+
+ $test -> case("Test Shortif regexp directly.",'3');
+ my $nd_root = CNFNode::_createNode('root');
+ CNFNode::_parseShortife( \$nd_root, q(
+ div__\
+ test __\
+ _______//
+
+ ));
+
+ CNFNode::_parseShortife( \$nd_root, q(
+ div__\
+ a:1
+ b:2
+ child1__\
+ has a value
+ __/
+ child2__\
+ __/
+ c:3
+ chd2 __\
+ a __\
+ b ___\
+ c ____\
+ d _____\
+ ___/////
+ chd3 __\
+ __/
+ __/
+ ));
+
+
+
+ #say $nd_root->toScript();
+
+ $test -> isDefined("Root node has div?",$nd_root->node('div'));
+ $test -> evaluate ("Root node has div/a == 1?",1, $nd_root->node('div/a'));
+ $test -> evaluate ("Root node has div/b == 2?",2, $nd_root->node('div/b'));
+ $test -> evaluate ("Root node has div/c == 3?",3, $nd_root->node('div/c'));
+ $test -> evaluate ("Root node has div/child1?",'has a value', $nd_root->node('div/child1')->val());
+ my $non_existent = $nd_root ->node('div/d');
+ $test -> isZeroOrEqual ("Root node has div/d == 0?", $non_existent->val(), 0);
+ my $deep = $nd_root->node('div/chd2/a/b/c/d');
+ $test -> isDefined ("Root node has div/chd2/a/b/c/d ?", $deep);
+
+
+
###
- $test -> case("Test typeglob as attribute type of constance.");
+ $test -> case("Test typeglob as attribute type of constance.",'4');
$test -> evaluate('Is *Globetroter main attribute eq to "TEST"',
'TEST', $Constants::GlobelTroter);
# man:: package GlobelTroter;
###
###
- $test -> case("Test shortife from file test.cnf.");
+ $test -> case("Test shortife from file test.cnf.",'5');
my $parser = CNFParser->new('test.cnf');
my @para_instructed = $parser->list("paragraphs");
my @paragraphs = $parser->listProcessed("paragraphs");
###
$test->nextCase();
###
- $test -> case("Test CNF frome test.cnf.");
+ $test -> case("Test CNF from test.cnf.",'6');
my $node = $parser->anon("paragraphs0");
$test-> isDefined("\$node",$node);
#TODO Currently doesn't work with shortifes parsed nodes to return expected -> my $divs = $node->find("content/div/*");
- my $content = $node->find('content/div');
+ my $content = $node->search('content/div');
my @divs = @{$content->{'@$'}};
$test -> evaluate("Does [".$content->name()."] have 2 child nodes?",2,scalar(@divs));
#TODO Following not working at the moment:
#say $node->toScript();
- my $div1 = $node->find('content/div/div1');
+ my $div1 = $node->search('content/div/div1');
$test->failed('content/div/div1 not found!') if not $test->isDefined("div1",$div1);
$test->evaluate('content/div/div1[class] value matches?','paragraph',$div1->{class});
- say $node->toScript();
+ #say $node->toScript();
+
+
+ $test -> case("Test shortife from file test.cnf with nested nodes.",'7');
+ my $meta = $parser -> anon('meta');
+ $test->failed("meta shortif is not defined!") if not $test->isDefined("meta",$meta);
+ # A node can have a list of other nodes in an array style.
+ my $items = $meta->list();
+ $test->failed("meta shortif has no list items!") if not $test->isDefined("\$meta->list()",$items);
+ my $count = @$items;
+ $test->evaluate("We expect 2 unnamed items in list.",2,$count);
+
+ $test -> case("Test wild by tag name a root.",'8');
+ $node -> process( $parser, q(
+ ___IN_SHORTIFE__ Users __\
+
+ User$$ __\
+ Details__\
+ Name : Albert
+ Surname : Cotton
+ DOB : 20-01-1998
+ alias : cottona
+ Address __\
+ _NOT_DISCLOSED_ __~
+ __///
+
+ User$$ __\
+ Details__\
+ Name : Baldrick
+ Surname : Cotton
+ DOB : 08-07-2003
+ alias : cottonb
+ Address __\
+ _NOT_DISCLOSED_ __~
+ __///
+
+ __/
+));
+ my $users = $node -> search('Users/User*');
+ $test->evaluate('search(Users/User*) == 2 of them?',2,scalar(@$users));
+ $test->subcase("Test User Details.");
+ foreach my$user(@$users){
+ if(my $details = $user->node('Details')){
+ $test -> failed("Not matching expected: [" . $user->toPath(). "] ->".$user->toScript())
+ if(
+ $details->{Name} ne 'Albert' and
+ $details->{Name} ne 'Baldrick'
+ or
+ $details->{Surname} ne 'Cotton'
+ )
+ }else{
+ $test -> failed("User has no [Details] node : ]" . $user->toPath() . "] ->".$user->toScript())
+ }
+ if(my $alias = $user->node('Details/alias')){
+ $test -> failed("Not matching expected: [" . $alias. "] for ->".$user->toScript())
+ if(
+ $alias ne 'cottona' and $alias ne 'cottonb'
+
+ )
+
+ }else{
+ $test -> failed("User has no [Details/alias] attribute: ]" . $user->toPath() . "] ->".$user->toScript())
+ }
+ }
+
###
$test->done();
#
my $html = $parser->data()->{'test1'};
my $tree = $parser->anon('test1');
die 'Not defined $tree' if !$tree;
- my $images = $tree->find('list_images');
+ my $images = $tree->search('list_images');
my $arr = $images->{'@@'};
die "Not expected size!" if @$arr != 2;
#do not now bark at the wrong tree from before, we reassigning tree with:
$tree = $parser->anon('test2');
die 'Not defined $tree2' if !$tree;
- my $val = $tree->find('anon_value3');
+ my $val = $tree->search('anon_value3');
$test -> isDefined("\$tree->find('anon_value3')",$val);
$test -> evaluate($val,"REACHED 3!");
$test->subcase("Check embeded link to a perl constance <*<MarkdownPlugin::CSS>*>");
my $style = $parser->anon('HTML_STYLE');
$test->isDefined('$style',$style);
- my @ret = $style->find('Content/MarkdownPlugin::CSS');
+ my @ret = $style->search('Content/MarkdownPlugin::CSS');
my $script = $ret[0];
if($test->isDefined('$script',$script)){
if ($script->val() !~ m/\.B\s\{/gm){
$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);
- my $url_node = $$perl_weekly->find("/Feed/URL");
+ my $url_node = $$perl_weekly->search("/Feed/URL");
$test->isDefined("Has an URL defined node?",$url_node);
$test->evaluate("CNF_FEED/Feed/URL is ok?","https://perlweekly.com/perlweekly.rss",$url_node);
}else{
#!/usr/bin/env perl
-use warnings; use strict;
+use warnings; use strict;
use Syntax::Keyword::Try;
use lib "tests";
use lib "system/modules";
+#use lib "system/modules";
require TestManager;
try{
$test->case("Test nested multiline value.");
- my $property = ${CNFNode->new({name=>'TEST'})->process(CNFParser->new(), qq(
+ my $property = ${CNFNode->new({name=>'TEST'})->process(CNFParser->new(), qq(
[a[
[b[
[#[
3
]#]
- ]b]
+ ]b]
]a]
[cell[
[#[
<img src="images/PerlCNF.png" style="float:left"/>
<a name="top"></a><a href="#bottom">To Bottom</a>
- ]#]
- ]cell]
+ ]#]
+ ]cell]
))};
-
- my $prp = $property->find('cell');
+
+ my $prp = $property->search('cell');
$test ->isDefined('cell', $prp);
print $prp->val();
- $prp = $property->find('a/b');
- $test ->isDefined('a/b', $prp);
- $test ->evaluate('a/b=1\n2\n3\n', $prp->val(),"1\n2\n3\n");
+ $prp = $property->search('a/b');
+ $test ->isDefined('Payj:a/b', $prp);
+ $test ->evaluate('Path:a/b=1\n2\n3\n', $prp->val(),"1\n2\n3\n");
#
###
# Test instance with cnf file creation.
- ###
+ ###
$test->case("Check Tree Algorithm.");
-my $for_html = q(
+my $for_html = q(
<div<
<div<
<div<
>div>
<div<
[#[
- Other text
+ Other text.
]#]
>div>
>div>
);
$prp = ${CNFNode->new({name=>'TEST'})->process(CNFParser->new(),$for_html)};
-my $nested = $prp->find('div/div/div/[0]/#');
-$test->evaluate("div/div/div/{0}/#",$nested,"This sample is more HTML look alike type of scheme.");
+my $nested = $prp->search('/div/div/div/[0]/#');
+$test->evaluate("/div/div/div/[0]/#",$nested,"This sample is more HTML look alike type of scheme.");
+$nested = $prp->search('/div/div/div/[1]/#');
+$test->evaluate("/div/div/div/[1]/#",$nested,"Other text.");
-my $nada = $prp->find('nada');
+my $nada = $prp->search('nada');
$test->isNotDefined("\$nada",@$nada);
-$nada = $prp->find('@$');
+$nada = $prp->search('@$');
$test->isDefined("TEST/@\$ properties subroperties",$nada);
-$nada = $prp->find('test/#');
+$nada = $prp->search('test/#');
$test->evaluate("\$TEST/test",$nada,'me too');
# my $tree = q{
# [node[
# [h1[ Hello World! ]h1]
- # ]node]
+ # ]node]
# };
# my $tree = q{
- # [node[
+ # [node[
# <div<
# a:1
# <div<
# b2:
# >div>
# >div>
- # ]node]
+ # ]node]
# };
my $tree = q{
- [node[
+ [node[
a:1
b=2
[1[
[2[
[#[ World! ]#]
]2]
- ]node]
+ ]node]
};
$property = ${CNFNode->new({name=>'TEST'})->process(CNFParser->new(),$tree)};
# my %node = %${node($node, 'node/1/2/3')};
# print "[[".$node{'#'}."]]\n";
-
+
# print "[[".%$$node{'#'}."]]\n";
# $node = node($node, 'node/1/2/3/a');
- my $hello = $property->find('node/1/#');
- my $world = $property->find('node/2/#');
+ my $hello = $property->search('node/1/#');
+ my $world = $property->search('node/2/#');
$test -> evaluate("[[$hello]]",$hello, "Hello my\n"); #<- nl is simulated, not automaticaly assumed with multi values taged
$test -> evaluate("[[$world]]",$world,' World! ');
-
+
#
- $test->nextCase();
+ $test->nextCase();
#
$cnf = CNFParser->new()->parse(undef,qq(
my $doc = $cnf->anon('DOC');
$test ->evaluate("\$doc->name() eg 'DOC'",$doc->name(),"DOC") ;
- my $c = $doc->find('c');
- $test ->isDefined("doc/c", $c);
+ my $c = $doc->search('c');
+ $test ->isDefined("doc/c", $c);
$test ->evaluate("Node 'DOC/c' eq 'cccc'", $c->val(), 'cccc');
$test ->evaluate("App link is set", $doc->{APP},$app);
#
- $test->nextCase();
+ $test->nextCase();
#
$test->case("Test find by path."); #4
- my $val = $doc->find('c/2');
+ my $val = $doc->search('c/2');
$test ->evaluate("Node 'DOC/c/2' eq 'barracuda'", $val, 'barracuda');
#
- $test->nextCase();
+ $test->nextCase();
#
$test->case("Test Array parsing."); #5
[@@[On single line]@@]
<@@<
One value.
- ]@@]
+ ]@@]
[@@[
Second value.
]@@]
<prop<
- some attribute = Something inbetween!
+ some attribute = Something in between!
>prop>
[@@[
Third value.
- ]@@]
+ ]@@]
[@@[
-
+
[p1[
a:1
b:2
]@@]
>node>
};
-
- # $tree = q{
- # <node<
- # [@@[
- # [p1[
- # a:1
- # b:2
- # ]p1]
- # [#[ Fourth value. ]/#]
- # ]@@]
- # [@@[
- # [p2[
- # aa:1
- # b:2
- # ]/p2]
- # ]@@]
- # >node>
- # };
-
+
+
$property = ${CNFNode->new({name=>'TEST ARRAY'})->process($cnf,$tree)};
- my $node = $property->find('node/@@');
+ my $node = $property->search('node/@@');
$test->isDefined('node/@@', $node);
$test->evaluate('node/@@', scalar(@$node),5);
- my $prop = $property->find('node/prop');
- $test ->isDefined('node/prop', $prop);
- $test->evaluate('node/prop[{attribue}->val()', $prop->{'some attribute'}, 'Something inbetween!');
-
- $node = $property->find('node/@@/p1');
+ my $prop = $property->search('node/prop');
+ $test ->isDefined('node/prop', $prop);
+ $test->evaluate('node/prop[{attribue}->val()', 'Something in between!', $prop->{'some attribute'});
+
+ $node = $property->search('node/@@/p1');
$test->isDefined('node/@@/p1', $node);
- $val = $property->find('node/@@/p1/b');
+ $val = $property->search('node/@@/p1/b');
$test->isDefined('node/@@/p1/b', $val);
$test->evaluate('node/@@/p1/b', $val, '2' );
- #
- $test->done();
+ #
+ $test->done();
#
}
-catch {
+catch {
$test -> dumpTermination($@);
$test -> doneFailed();
}