Also posted to my use.perl journal and the Perl-QA list.
There are many times when we test string data but whitespace issues give us false negatives. For example, consider the following two SQL snippets:
CREATE TABLE foo ( id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(32) NOT NULL, age INTEGER );
And:
create table foo ( id INTEGER NOT NULL PRIMARY KEY, name VARCHAR(32) NOT NULL, age integer );
Those are functionally equivalent but there are a few potential problems with testing it. I can get a reasonably easy to debug test if I do the following:
I can use Data::Record to easily split the string on spaces without affecting quoted characters:
use Regexp::Common; use Data::Record; my $record = Data::Record->new({ split => qr/\s\t/, unless => $RE{quoted}, }); my $data = join ' ', map { lc $_ } $record->records($data);
That doesn't seem flexible enough, though. It would be useful to wrap this in a test module whereby one can control whether or not one wants to alter the case, ignore quoted data, preseve newlines, and so on. I could make a plethora of test functions, but the number of possible combinations would make them unweildy. I could have the user set the parameters at the top of the test and change the parameters as needed. This would make this far more flexible than simply an SQL tester. Thoughts?
I'm thinking a name like Test::ControlWhitespace.
Cheers,
Ovid
New address of my CGI Course.
In reply to Whitespace issues in testing by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |