my @expect;
+sub sort_set {
+ sort { $a->{name} cmp $b->{name} } @_
+}
+
{
unlink('tmp.db');
my $dbh = DBI->connect($dsn);
my $pop = $dbh->prepare(q{INSERT INTO person (name) VALUES (?)});
my @names = qw(Joe Jim Bob Pterry);
$pop->execute($_) for @names;
- @expect = do { my $id = 0; map +{ id => ++$id, name => $_ }, @names };
+ @expect = sort_set do {
+ my $id = 0; map +{ id => ++$id, name => $_ }, @names
+ };
}
sub make_set {
my $set = make_set;
-is_deeply([ $set->flatten ], \@expect, 'Basic data out ok (flatten)');
+is_deeply([ sort_set $set->flatten ], \@expect, 'Basic data out ok (flatten)');
{
my $stream = $set->as_stream;
my @got; while (my ($next) = $stream->next) { push @got, $next }
- is_deeply(\@got, \@expect, 'Basic data out ok (stream)');
+ is_deeply([ sort_set @got ], \@expect, 'Basic data out ok (stream)');
}
$set = make_set { class => 'Spoon' };
is_deeply(
- [ $set->flatten ],
+ [ sort_set $set->flatten ],
[ map { bless({ %$_ }, 'Spoon') } @expect ],
'Basic data with class out ok'
);