No Moose Change
Another test postette here in the Moos-Pen today.
To finish off the '30_where_basic.t' test case I decided to add one more test; the function from hell;
(abs((People.salary + .05) * 1.5))*People.overtime+(abs(People.salary+.05)
*2)*People.doubletime)
I diligently set that test up and then when I ran it I got
# Expected SQL--> SELECT people.first_name, people.last_name, people.user_id FROM
people WHERE ((abs(people.salary + ?) * ?) * people.overtime) + ((abs(people.salary + ?) * ?) * people.doubletime) != ?
# Generated SQL-> SELECT people.first_name First, people.last_name Last, people.user_id "User ID" FROM
people WHERE ((abs(people.salary + ?) * ?) * people.overtime) + ((abs(people.salary + ?) * ?) * people.doubletime) != ?
the conditional part was correct but I was getting the elements left over from my last test. Opps!
Good old perl I always forget it always passes by references so I am kludging that $in_hash of mine when I change the 'elements' in the last test they stick around until I change them back.
I was thinking of doing a copy of the $in_hash ;
sub sql_param_ok {
my $self = shift;
my ( $org_hash, $tests ) = @_;
my $in_hash = $org_hash;
…
which of course not work because that $in_hash is now just a reference to a references which is the same thing. I could try a copy like this
my %in_hash = %{$org_hash};
but that would only be one level and I would miss all sort of things. I really am faced with using something on the line of 'Clone', 'Hash::Copy' or alike. In the end I think I will just change my expected results to comply with the current set of 'elements'. Just too much bother to do otherwise as all I need to do is a simple cut and past form the last test expeded sql.
No elegant but I do not want to get into a tail- wagging dog situation when my utilities for testing take more time to code than the system the test.
Well not much of a post today.
Leave a comment