From: Johannes Plunien Date: Sun, 3 May 2009 09:13:48 +0000 (+0000) Subject: Using "is" instead of "cmp_ok" X-Git-Tag: v0.08103~117^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb9b5b23a0f1487c92a609af81b97dd1ed710ff1;p=dbsrgits%2FDBIx-Class.git Using "is" instead of "cmp_ok" --- diff --git a/t/53delete_chained.t b/t/53delete_chained.t index 6d06be9..5a5c3ce 100644 --- a/t/53delete_chained.t +++ b/t/53delete_chained.t @@ -28,7 +28,7 @@ cmp_ok($total_tracks, '>', 0, 'need track records'); my $rs = $artist->cds->search_related('tracks'); $total_tracks -= $rs->count; ok($rs->delete); - cmp_ok($schema->resultset('Track')->count, '==', $total_tracks, '3 tracks should be deleted'); + is($schema->resultset('Track')->count, $total_tracks, '3 tracks should be deleted'); } # test that delete_related w/conditions deletes just the matched related records only @@ -43,5 +43,5 @@ cmp_ok($total_tracks, '>', 0, 'need track records'); my $rs = $artist2->search_related('cds')->search_related('tracks'); $total_tracks -= $rs->count; ok($rs->delete); - cmp_ok($schema->resultset('Track')->count, '==', $total_tracks, 'No tracks should be deleted'); + is($schema->resultset('Track')->count, $total_tracks, 'No tracks should be deleted'); } diff --git a/t/76joins.t b/t/76joins.t index f5ab52d..39a51d3 100644 --- a/t/76joins.t +++ b/t/76joins.t @@ -140,7 +140,7 @@ my $rs = $schema->resultset("CD")->search( ] ] } ); -cmp_ok( $rs + 0, '==', 1, "Single record in resultset"); +is( $rs + 0, 1, "Single record in resultset"); is($rs->first->title, 'Forkful of bees', 'Correct record returned'); @@ -148,7 +148,7 @@ $rs = $schema->resultset("CD")->search( { 'year' => 2001, 'artist.name' => 'Caterwauler McCrae' }, { join => 'artist' }); -cmp_ok( $rs + 0, '==', 1, "Single record in resultset"); +is( $rs + 0, 1, "Single record in resultset"); is($rs->first->title, 'Forkful of bees', 'Correct record returned'); @@ -157,7 +157,7 @@ $rs = $schema->resultset("CD")->search( 'liner_notes.notes' => 'Kill Yourself!' }, { join => [ qw/artist liner_notes/ ] }); -cmp_ok( $rs + 0, '==', 1, "Single record in resultset"); +is( $rs + 0, 1, "Single record in resultset"); is($rs->first->title, 'Come Be Depressed With Us', 'Correct record returned'); @@ -166,7 +166,7 @@ $rs = $schema->resultset("CD")->search( { 'artist' => 1 }, { join => [qw/artist/], order_by => 'artist.name' } ); -cmp_ok( scalar $rs->all, '==', scalar $rs->slice(0, $rs->count - 1), 'slice() with join has same count as all()' ); +is( scalar $rs->all, scalar $rs->slice(0, $rs->count - 1), 'slice() with join has same count as all()' ); ok(!$rs->slice($rs->count+1000, $rs->count+1002)->count, 'Slicing beyond end of rs returns a zero count'); @@ -175,7 +175,7 @@ $rs = $schema->resultset("Artist")->search( { 'liner_notes.notes' => 'Kill Yourself!' }, { join => { 'cds' => 'liner_notes' } }); -cmp_ok( $rs->count, '==', 1, "Single record in resultset"); +is( $rs->count, 1, "Single record in resultset"); is($rs->first->name, 'We Are Goth', 'Correct record returned'); @@ -206,8 +206,8 @@ is($rs->first->name, 'We Are Goth', 'Correct record returned'); return $schema->resultset("TwoKeys")->count; } - cmp_ok(cd_count(), '==', 8, '8 rows in table cd'); - cmp_ok(tk_count(), '==', 7, '7 rows in table twokeys'); + is(cd_count(), 8, '8 rows in table cd'); + is(tk_count(), 7, '7 rows in table twokeys'); sub artist1 { return $schema->resultset("CD")->search( @@ -222,13 +222,13 @@ is($rs->first->name, 'We Are Goth', 'Correct record returned'); ); } - cmp_ok( artist1()->count, '==', 3, '3 Caterwauler McCrae CDs' ); + is( artist1()->count, 3, '3 Caterwauler McCrae CDs' ); ok( artist1()->delete, 'Successfully deleted 3 CDs' ); - cmp_ok( artist1()->count, '==', 0, '0 Caterwauler McCrae CDs' ); - cmp_ok( artist2()->count, '==', 2, '3 Random Boy Band CDs' ); + is( artist1()->count, 0, '0 Caterwauler McCrae CDs' ); + is( artist2()->count, 2, '3 Random Boy Band CDs' ); ok( artist2()->update( { 'artist' => 1 } ) ); - cmp_ok( artist2()->count, '==', 0, '0 Random Boy Band CDs' ); - cmp_ok( artist1()->count, '==', 2, '2 Caterwauler McCrae CDs' ); + is( artist2()->count, 0, '0 Random Boy Band CDs' ); + is( artist1()->count, 2, '2 Caterwauler McCrae CDs' ); # test update on multi-column-pk sub tk1 { @@ -246,12 +246,12 @@ is($rs->first->name, 'We Are Goth', 'Correct record returned'); { join => [qw/artist/]} ); } - cmp_ok( tk2()->count, '==', 2, 'TwoKeys count == 2' ); - cmp_ok( tk1()->count, '==', 2, 'TwoKeys count == 2' ); + is( tk2()->count, 2, 'TwoKeys count == 2' ); + is( tk1()->count, 2, 'TwoKeys count == 2' ); ok( tk1()->update( { artist => 1 } ) ); - cmp_ok( tk1()->count, '==', 0, 'TwoKeys count == 0' ); - cmp_ok( tk2()->count, '==', 4, '2 Caterwauler McCrae CDs' ); + is( tk1()->count, 0, 'TwoKeys count == 0' ); + is( tk2()->count, 4, '2 Caterwauler McCrae CDs' ); ok( tk2()->delete, 'Successfully deleted 4 CDs' ); - cmp_ok(cd_count(), '==', 5, '5 rows in table cd'); - cmp_ok(tk_count(), '==', 3, '3 rows in table twokeys'); + is(cd_count(), 5, '5 rows in table cd'); + is(tk_count(), 3, '3 rows in table twokeys'); } diff --git a/t/resultset/as_query.t b/t/resultset/as_query.t index 5e9a7fe..4d593de 100644 --- a/t/resultset/as_query.t +++ b/t/resultset/as_query.t @@ -79,7 +79,7 @@ my $rscol = $art_rs->get_column( 'charfield' ); [['artist.name' => 'Caterwauler McCrae']] ); my $subsel_rs = $schema->resultset("CD")->search( { cdid => { IN => $query } } ); - cmp_ok($subsel_rs->count, '==', $rs->count, 'Subselect on PK got the same row count'); + is($subsel_rs->count, $rs->count, 'Subselect on PK got the same row count'); } __END__