> On Jun 24, 2016, at 12:57 PM, Buddy Burden <barefootco...@gmail.com> wrote: > > What sort of methods did you have in mind? I might have something to > contribute, if you would be interested in contributions.
I’ve accumulated a number of test functions in our work codebase for doing what I call “expressive” tests to avoid common cut & paste. I’m using the term “expressive” for now because they’re expressing what it is you want, rather than making you write the code that explains them. For instance, instead of doing all the is( scalar @{$foo}, 0 ); # Is this an empty array? ok( scalar @{$foo} ); # Is there something in the array? I’ve been writing is_empty_array( $foo ); is_nonempty_array( $foo ); because I believe that it’s easier to read the English “is empty array” than to translate “is( scalar @{$foo}, 0 )” into that meaning. We’ve got some 1200+ .t files of 11MB so I do a lot of reading of .t files all day. Similarly: is_nonblank( $response ); is_blank( $response ); instead of ok( defined($response) ) && like( $response, qr/./ ); is( $response, ‘’ ); for the same reasons. They’re common idioms, but I’d still rather read English than Perl. Also, I see it that the fewer arguments passed around, the fewer places for mistakes. I’ve also stolen some stuff from Test::Numeric for common tests. is_integer, is_positive_integer, is_nonnegative_integer, is_even. I’ve also got things like all_keys_exist_in( \%hash, [qw( foo bar bat )] ). … Now, with Test2, my thinking on many of these changes. The odious is( scalar @{$foo}, 0 ); now becomes simply is( $foo, [] ); which may not be as Englishy as is_empty_array( $foo ) but that I am probably fine with. So, too, does something like all_keys_exist_in() become much easier to do with the new DSL in Test2. But there will still be others like it, I suspect. … I also want to have something that is an example of the Right Way To Do It that we can point at as an add-on distribution to Test2::Suite. I think that will help future Test2::Tools writers. So those are my high-level thoughts. -- Andy Lester => www.petdance.com