goibhniu has asked for the wisdom of the Perl Monks concerning the following question:
I have some perl modules that were left behind by some consultants. They didn't use strict (and when they set stuff up I didn't know enough to make them). I'm trying to extend their work and reuse their code, but it's kludgey, doesn't use strict and some of it just doesn't work.
So I've set about to refactor. I'm trying to build in some safety nets and I'm trying to do some things right. Here's what I've done:
I'm getting a little stuck on the baselining and test harnessing. I haven't used Test::Anything before and am reading those. I started with:
perl -lne "print $1 if /^\W*sub (.*)/i" harcommon.pm
to get a list of subs and then wrote this (with help from chatterboxers) to test them:
#!/usr/bin/perl use harcommon; my @funclist = qw(udpinifile colsep remove_duplicates runsql runhsql get_ini_setting create_min_ini delete_min_ini get_ini_file get_os get_tempdir get_s +lash file_exists display_text debug trim rtrim ltrim date_string extension_in_list string_in_list unlock_user exiterror capture_file + transfer_file delete_file execute_cmd find_user_home version get_cl +ear_pass get_pass get_vp get_full_item get_item get_version_num get_ext get_item_minus_ext); my %dispatch; #$dispatch{$_}=*{$_}{'CODE'} foreach @funclist; #also works $dispatch{$_}=\&{"harcommon::$_"} foreach @funclist; { local $\="\n"; foreach my $func (@funclist) { print '==========================='; print $func; #print $dispatch{$func}; print '==========================='; print harcommon->$func() } }
Some of their functions run without args, some work without args but give screwy results, some kill the script and block the rest of the tests. I want to go function by function and make a set of test args so at least I'm calling them in good faith for the baseline. What data structure should I use to represent the function args?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Data Structures design help to represent function args for testing
by Joost (Canon) on Sep 20, 2007 at 21:38 UTC | |
by goibhniu (Hermit) on Sep 21, 2007 at 00:50 UTC | |
by GrandFather (Saint) on Sep 21, 2007 at 03:06 UTC | |
|
Re: Data Structures design help to represent function args for testing
by rvosa (Curate) on Sep 21, 2007 at 07:03 UTC | |
by goibhniu (Hermit) on Sep 21, 2007 at 13:56 UTC |