in reply to Re: Data Structures design help to represent function args for testing
in thread Data Structures design help to represent function args for testing

Wonderful - that's the kind of data structure I was looking for. Each arg list as an array. Each @funclist as the key to a hash pointing to the arg list.

Any suggestions for a good data structure if I want more than one test list of args per function? (not a requirement in the original post - I'm just exploring the design space).


I humbly seek wisdom.
  • Comment on Re^2: Data Structures design help to represent function args for testing

Replies are listed 'Best First'.
Re^3: Data Structures design help to represent function args for testing
by GrandFather (Saint) on Sep 21, 2007 at 03:06 UTC

    You're taking it up one level, so extrapolate the argument solution up one level - use a hash of arrays or an array of arrays:

    my %functions = ( function1 => {arglist1 => ["arg1", { arg2 => val2 }], arglist2 => [...], ... }, function2 => {...}, ..., ); while (my ($func, $argsList) = each %functions) { for my $key (keys %$argsList) { print "Test $func against args $key\n" &{"harcommon::$func"}(@{$argsList->{$key}}); } }

    or:

    my %functions = ( function1 => [["arg1", { arg2 => val2 }], [...], ... ], function2 => [...], ..., ); while (my ($func, $argsList) = each %functions) { for my $args (@$argsList) { print "Test $func against args $key\n" &{"harcommon::$func"}(@$args); } }

    Perl is environmentally friendly - it saves trees