X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F101populate_rs.t;h=7f356d9df57e3bc80d0e1f67c324c4f6b68ca762;hb=293cb2f1de2a488aa6062036deac8a562e8e16c6;hp=a592e56ebe5d82302bce88c4a93cc1fab4c84395;hpb=d0cefd99a98e7fb2304fe6a5182d321fe7c551fc;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/101populate_rs.t b/t/101populate_rs.t index a592e56..7f356d9 100644 --- a/t/101populate_rs.t +++ b/t/101populate_rs.t @@ -1,3 +1,5 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + ## ---------------------------------------------------------------------------- ## Tests for the $resultset->populate method. ## @@ -13,7 +15,8 @@ use warnings; use Test::More; use Test::Warn; -use lib qw(t/lib); +use Test::Exception; + use DBICTest; @@ -704,6 +707,26 @@ ARRAYREF_OF_ARRAYREF_STYLE: { } } -ok(eval { $art_rs->populate([]); 1 }, "Empty populate runs but does nothing"); +EMPTY_POPULATE: { + foreach( + [ empty => [] ], + [ columns_only => [ [qw(name rank charfield)] ] ], + ) { + my ($desc, $arg) = @{$_}; + + $schema->is_executed_sql_bind( sub { + + my $rs = $art_rs; + lives_ok { $rs->populate($arg); 1 } "$desc populate in void context lives"; + + my @r = $art_rs->populate($arg); + is_deeply( \@r, [], "$desc populate in list context returns empty list" ); + + my $r = $art_rs->populate($arg); + is( $r, undef, "$desc populate in scalar context returns undef" ); + + }, [], "$desc populate executed no statements" ); + } +} done_testing;