(moving this to perl-qa because we decided to retire test-users)
On 2011.3.30 6:52 AM, Michael Ludwig wrote: > Michael G Schwern schrieb am 27.01.2011 um 12:09 (+1000): >> use Test::More; >> use Test::Builder2::Tester; >> >> my $history = capture { >> plan tests => 2; >> is "this", "that", "this is that"; >> ok 1, "pass"; >> }; >> >> my $plan = $history->plan; >> is $plan->asserts_expected, 2; >> >> my $results = $history->results; >> result_like $results->[0], { >> … > >> result_like $results->[1], { >> … > > I like a nice function syntax that doesn't require a lot of punctuation. > However, if you add a test to your capture block in a position other > than at the end, you'll have to update all the array indices, which is > awkward. The intention is to mitigate that by making your capture blocks small, but I hear ya. Good point. > Wouldn't it therefore be better to make a closure over the results that > maintains the array index for you? > > my $checker = make_result_checker $history->results; > $checker->( { > is_pass => 0, > name => "this is that", > file => $0, > } ); > $checker->( { > … > } ); Took me a moment to understand that. Would this cover your need? result_like shift @$results, { ... }; And it's not hard wired. If you like it, could I get you to document the concern and technique in an EXAMPLES section? https://github.com/schwern/test-more/blob/Test-Builder2/lib/Test/Builder2/Tester.pm -- 125. Two drink limit does not mean two kinds of drinks. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/