From: Matt S Trout Date: Fri, 8 Jan 2010 01:05:44 +0000 (+0000) Subject: make tests more robust X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d8eb0a3f9ef700cc22ea0ecf68906ee11bce53ae;hp=1e948dd4cabe92dedc033ccce3b1dded55b99b3e;p=dbsrgits%2FDBIx-Data-Store-old.git make tests more robust --- diff --git a/t/01basic_collection.t b/t/01basic_collection.t index 48f746b..7b744cf 100644 --- a/t/01basic_collection.t +++ b/t/01basic_collection.t @@ -11,6 +11,10 @@ my $dsn = 'dbi:SQLite:tmp.db'; my @expect; +sub sort_set { + sort { $a->{name} cmp $b->{name} } @_ +} + { unlink('tmp.db'); my $dbh = DBI->connect($dsn); @@ -23,7 +27,9 @@ my @expect; 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 { @@ -41,20 +47,20 @@ 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' );