A Mature Mosoe

Its another quick test postette today in the Moose-Pne

So things are moving along now I just just going to finish off '57_dad_elements.t so it will be a short one today. Nothing much to Add I just have to add in dynamic link, gather, and sort.

Well sort should by the most easy one so I will do that one first; All I did was copy out the last (5th) item in the main hash and added it in like this;


$da->add_sort({
expression => '+',
left => { name => 'salary', },
right => {
expression => '*',
left => { name => 'bonus', },
right => {
function => 'abs',
left => {
expression => '*',
left => {
name => 'bonus',
view => 'Other'
},
right => { name => 'bonus', }
}
}
}
});

Next a little re-factoring of the last four sort tests into a little loop


foreach my $i (4..5){
ok(
$elements->[4]->left->view eq 'People',
"Sort element index $i left inherits view"
);
ok(
$elements->[4]->right->left->view eq 'People',
"Sort element index $i right->left inherits view"
);
ok(
$elements->[4]->right->right->left->left->view eq 'Other',
"Sort element index $i right->right->left does not inherit view"
);
ok(
$elements->[4]->right->right->left->right->view eq 'People',
"Sort element index $i right->right->left->right inherits view"
);
}

and those tests where taken care of.

I did the same thing for Link whit this sort of iteration


$elements = $dad->links;
foreach my $i ( 0 .. 1 ) {
ok(
$elements->[$i]->conditions->[0]->predicates->left->view() eq 'People',
"Link index $i condition left inherit view"
);

finally gathers was a little special as it is a singleton attribute so I added in a new gather like this

$da->add_gather(
{
elements => [ { name => 'user_id', } ],
condtions => {
condition => 'AND',
left => {
expression => '*',
left => { name => 'bonus', },
right => {
function => 'abs',
left => {
expression => '*',
left => {
name => 'bonus',
view => 'Other'
},
right => { name => 'bonus', }
}
}
},
right => { name => 'First_2', },
operator => '=',
}
}
);

and adjusted the test to this

ok(
$elements->elements->[0]->view() eq 'People',
'First Gather element inherits view'
);
ok(
$elements->elements->[1]->view() eq 'Other People',
'Second Gather element does not inherit view'
);
ok(
$elements->elements->[0]->view() eq 'People',
'First Gather element inherits view'
);
ok(
$elements->elements->[1]->view() eq 'Other People',
'Second Gather element does not inherit view'
);
ok(
$elements->elements->[2]->view() eq 'People',
'Third Gather element inherits view'
);
ok( $elements->conditions->[0]->predicates->left->view() eq 'People',
"Gather condition index 0 left inherit view" );
ok(
$elements->conditions->[1]->predicates->left->view() eq 'Not People',
"Gather condition index 1 left does not inherit view"
);
ok( $elements->conditions->[2]->predicates->left->left->view() eq 'People',
"Gather condition index 2 left->left inherits view" );
ok( $elements->conditions->[2]->predicates->left->right->left->left->view() eq 'Other',
"Gather condition index 2 left->right->left->left does not inherit view" );
ok(
$elements->conditions->[2]->predicates->left->right->left->right->view() eq
'People',
"Gather condition index 2 left->right->left->right does not inherit view"
);
ok(
$elements->conditions->[2]->predicates->right->view() eq
'People',
"Gather condition index 2 right inherits view"
);

and then I get a fail

ok 46 - Second Gather element does not inherit view
not ok 47 - Third Gather element inherits view

and a

Can't call method "predicates" on an undefined value at 57_dad_elements.t line 486.
# Looks like your test exited with 255 just after 49.

so I looks like I have a little fix to to for tomorrow's postette;

hp3582.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations