r41247 - in /branches/upstream/libcddb-perl/current: CHANGES META.yml Makefile.PL lib/CDDB.pm t/01_cddb.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Mon Aug 3 16:42:52 UTC 2009


Author: jawnsy-guest
Date: Mon Aug  3 16:42:45 2009
New Revision: 41247

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=41247
Log:
[svn-upgrade] Integrating new upstream version, libcddb-perl (1.21)

Modified:
    branches/upstream/libcddb-perl/current/CHANGES
    branches/upstream/libcddb-perl/current/META.yml
    branches/upstream/libcddb-perl/current/Makefile.PL
    branches/upstream/libcddb-perl/current/lib/CDDB.pm
    branches/upstream/libcddb-perl/current/t/01_cddb.t

Modified: branches/upstream/libcddb-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcddb-perl/current/CHANGES?rev=41247&op=diff
==============================================================================
--- branches/upstream/libcddb-perl/current/CHANGES (original)
+++ branches/upstream/libcddb-perl/current/CHANGES Mon Aug  3 16:42:45 2009
@@ -1,25 +1,30 @@
-=========================
-2006-03-26 01:08:42 v1_17
-=========================
+=================================
+2009-07-27T16:02:08.268109Z v1_21
+=================================
 
-  2006-03-26 01:08:12 (r3) by rcaputo; lib/CDDB.pm M; t/01_cddb.t M
+  2009-07-27 16:01:44 (r9) by rcaputo; lib/CDDB.pm M
 
-    Apply Jasper Lievisse Adriaanse's patch to fix the tests. We're
-    testing live data, and it sometimes changes. Also incremented the
-    version number for a new release. 
+    Reorganize documentation links.
 
-  2005-09-17 19:54:22 (r2) by rcaputo
-  t/01_cddb.t A; t/cddb.t D; MANIFEST M
+  2009-07-27 04:39:24 (r8) by rcaputo; lib/CDDB.pm M; Makefile.PL M
 
-    Remove META.yml from the MANIFEST. Doesn't seem necessary now. Moved
-    the test to a numbered file. 
+    Add machine-readable repository directory. Add BUG TRACKER,
+    REPOSITORY and OTHER RESOURCES to the documentation. 
 
-  2005-09-17 19:46:28 (r1) by rcaputo
-  README A; devel/cddb-command-response-state.dia A; lib/CDDB.pm A; devel
-  A; /trunk A; HISTORY A; t/cddb.t A; /branches A; devel/get-toc.c A; t
-  A; lib A; MANIFEST A; Makefile.PL A; /tags A
+=================================
+2009-07-26T03:54:46.902679Z v1_20
+=================================
 
-    Initial import. 
+  2009-07-26 03:54:11 (r6) by rcaputo
+  lib/CDDB.pm M; t/01_cddb.t M; Makefile.PL M
+
+    Upgrade tests to Test::More. Fix track offset calculations according
+    to documented test input. Fix test input to match FreeDB
+    documentation. Many thanks to Chuck Cranor for reporting the issue. 
+
+  2006-11-06 19:20:39 (r5) by rcaputo; Makefile.PL M
+
+    Set a LICENSE. Cheap kwalitee points!
 
 ==============
 End of Excerpt

Modified: branches/upstream/libcddb-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcddb-perl/current/META.yml?rev=41247&op=diff
==============================================================================
--- branches/upstream/libcddb-perl/current/META.yml (original)
+++ branches/upstream/libcddb-perl/current/META.yml Mon Aug  3 16:42:45 2009
@@ -1,12 +1,25 @@
 --- #YAML:1.0
-name:                CDDB
-version:             1.17
-abstract:            High-level interface to CDDB and freedb servers.
-license:             unknown
-generated_by:        ExtUtils::MakeMaker version 6.30_01
-author:              Rocco Caputo <rcaputo at cpan.org>
-distribution_type:   module
-requires:     
+name:               CDDB
+version:            1.21
+abstract:           High-level interface to CDDB and freedb servers.
+author:
+    - Rocco Caputo <rcaputo at cpan.org>
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Test::More:  0
+resources:
+    license:     http://dev.perl.org/licenses/
+    repository:  http://thirdlobe.com/svn/cddb/trunk
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.54
 meta-spec:
-    url: <http://module-build.sourceforge.net/META-spec-new.html>;
-    version: 1.1
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: branches/upstream/libcddb-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcddb-perl/current/Makefile.PL?rev=41247&op=diff
==============================================================================
--- branches/upstream/libcddb-perl/current/Makefile.PL (original)
+++ branches/upstream/libcddb-perl/current/Makefile.PL Mon Aug  3 16:42:45 2009
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: Makefile.PL 1 2005-09-17 19:46:28Z rcaputo $
+# $Id: Makefile.PL 8 2009-07-27 04:39:24Z rcaputo $
 
 use ExtUtils::MakeMaker;
 
@@ -10,7 +10,17 @@
 	NAME         => 'CDDB',
 	AUTHOR       => 'Rocco Caputo <rcaputo at cpan.org>',
 	ABSTRACT     => 'High-level interface to CDDB and freedb servers.',
+	LICENSE      => 'perl',
 	VERSION_FROM => 'lib/CDDB.pm',
+	PREREQ_PM    => {
+		'Test::More' => 0,
+	},
+	META_ADD     => {
+		resources  => {
+			license    => 'http://dev.perl.org/licenses/',
+			repository => 'http://thirdlobe.com/svn/cddb/trunk'
+		},
+	},
 	dist         => {
 		COMPRESS   => 'gzip -9',
 		SUFFIX     => 'gz',

Modified: branches/upstream/libcddb-perl/current/lib/CDDB.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcddb-perl/current/lib/CDDB.pm?rev=41247&op=diff
==============================================================================
--- branches/upstream/libcddb-perl/current/lib/CDDB.pm (original)
+++ branches/upstream/libcddb-perl/current/lib/CDDB.pm Mon Aug  3 16:42:45 2009
@@ -1,4 +1,4 @@
-# $Id: CDDB.pm 3 2006-03-26 01:08:12Z rcaputo $
+# $Id: CDDB.pm 9 2009-07-27 16:01:44Z rcaputo $
 # Documentation and Copyright exist after __END__
 
 package CDDB;
@@ -8,7 +8,7 @@
 use vars qw($VERSION);
 use Carp;
 
-$VERSION = '1.17';
+$VERSION = '1.21';
 
 BEGIN {
 	if ($^O eq 'MSWin32') {
@@ -516,7 +516,7 @@
 
 	foreach my $line (@toc) {
 		my ($track, $mm_begin, $ss_begin, $ff_begin) = split(/\s+/, $line, 4);
-		my $frame_offset = (($mm_begin * 60 + $ss_begin) * 75) + $ff_begin + 150;
+		my $frame_offset = (($mm_begin * 60 + $ss_begin) * 75) + $ff_begin;
 		my $seconds_begin = int($frame_offset / 75);
 
 		if (defined $seconds_previous) {
@@ -550,10 +550,10 @@
 
 	# Calculate the ID.  Whee!
 	my $id = sprintf(
-		"%08x",
-		(($cddbp_sum % 255) << 24)
-		| (($seconds_last - $seconds_first) << 8)
-		| scalar(@track_offsets)
+		"%02x%04x%02x",
+		($cddbp_sum % 255),
+		$seconds_last - $seconds_first,
+		 scalar(@track_offsets)
 	);
 
 	# In list context, we return several things.  Some of them are
@@ -1022,67 +1022,67 @@
 
 =head1 SYNOPSIS
 
-	use CDDB;
-
-	### Connect to the cddbp server.
-	my $cddbp = new CDDB(
-		Host  => 'freedb.freedb.org', # default
-		Port  => 8880,                # default
-		Login => $login_id,           # defaults to %ENV's
-	) or die $!;
-
-	### Retrieve known genres.
-	my @genres = $cddbp->get_genres();
-
-	### Calculate cddbp ID based on MSF info.
-	my @toc = (
-		'1    0  2 37',           # track, CD-i MSF (space-delimited)
-		'999  1 38 17',           # lead-out track MSF
-		'1000 0  0 Error!',       # error track (don't include if ok)
-	);
-	my (
-		$cddbp_id,      # used for further cddbp queries
-		$track_numbers, # padded with 0's (for convenience)
-		$track_lengths, # length of each track, in MM:SS format
-		$track_offsets, # absolute offsets (used for further cddbp queries)
-		$total_seconds  # total play time, in seconds (for cddbp queries)
-	 ) = $cddbp->calculate_id(@toc);
-
-	### Query discs based on cddbp ID and other information.
-	my @discs = $cddbp->get_discs($cddbp_id, $track_offsets, $total_seconds);
-	foreach my $disc (@discs) {
-		my ($genre, $cddbp_id, $title) = @$disc;
-	}
-
-	### Query disc details (usually done with get_discs() information).
-	my $disc_info     = $cddbp->get_disc_details($genre, $cddbp_id);
-	my $disc_time     = $disc_info->{'disc length'};
-	my $disc_id       = $disc_info->{discid};
-	my $disc_title    = $disc_info->{dtitle};
-	my @track_offsets = @{$disc_info->{offsets}};
-	my @track_seconds = @{$disc_info->{seconds}};
-	my @track_titles  = @{$disc_info->{ttitles}};
-	# other information may be returned... explore!
-
-	### Submit a disc via e-mail. (Requires MailTools)
-
-	die "can't submit a disc (no mail modules; see README)"
-		unless $cddbp->can_submit_disc();
-
-	# These are useful for prompting the user to fix defaults:
-	print "I will send mail through: ", $cddbp->get_mail_host(), "\n";
-	print "I assume your e-mail address is: ", $cddbp->get_mail_address(), "\n";
-
-	# Actually submit a disc record.
-	$cddbp->submit_disc(
-		Genre       => 'classical',
-		Id          => 'b811a20c',
-		Artist      => 'Various',
-		DiscTitle   => 'Cartoon Classics',
-		Offsets     => $disc_info->{offsets},   # array reference
-		TrackTitles => $disc_info->{ttitles},   # array reference
-		From        => 'login at host.domain.etc', # will try to determine
-	);
+  use CDDB;
+
+  ### Connect to the cddbp server.
+  my $cddbp = new CDDB(
+    Host  => 'freedb.freedb.org', # default
+    Port  => 8880,                # default
+    Login => $login_id,           # defaults to %ENV's
+  ) or die $!;
+
+  ### Retrieve known genres.
+  my @genres = $cddbp->get_genres();
+
+  ### Calculate cddbp ID based on MSF info.
+  my @toc = (
+    '1    0  2 37',           # track, CD-i MSF (space-delimited)
+    '999  1 38 17',           # lead-out track MSF
+    '1000 0  0 Error!',       # error track (don't include if ok)
+  );
+  my (
+    $cddbp_id,      # used for further cddbp queries
+    $track_numbers, # padded with 0's (for convenience)
+    $track_lengths, # length of each track, in MM:SS format
+    $track_offsets, # absolute offsets (used for further cddbp queries)
+    $total_seconds  # total play time, in seconds (for cddbp queries)
+   ) = $cddbp->calculate_id(@toc);
+
+  ### Query discs based on cddbp ID and other information.
+  my @discs = $cddbp->get_discs($cddbp_id, $track_offsets, $total_seconds);
+  foreach my $disc (@discs) {
+    my ($genre, $cddbp_id, $title) = @$disc;
+  }
+
+  ### Query disc details (usually done with get_discs() information).
+  my $disc_info     = $cddbp->get_disc_details($genre, $cddbp_id);
+  my $disc_time     = $disc_info->{'disc length'};
+  my $disc_id       = $disc_info->{discid};
+  my $disc_title    = $disc_info->{dtitle};
+  my @track_offsets = @{$disc_info->{offsets}};
+  my @track_seconds = @{$disc_info->{seconds}};
+  my @track_titles  = @{$disc_info->{ttitles}};
+  # other information may be returned... explore!
+
+  ### Submit a disc via e-mail. (Requires MailTools)
+
+  die "can't submit a disc (no mail modules; see README)"
+    unless $cddbp->can_submit_disc();
+
+  # These are useful for prompting the user to fix defaults:
+  print "I will send mail through: ", $cddbp->get_mail_host(), "\n";
+  print "I assume your e-mail address is: ", $cddbp->get_mail_address(), "\n";
+
+  # Actually submit a disc record.
+  $cddbp->submit_disc(
+    Genre       => 'classical',
+    Id          => 'b811a20c',
+    Artist      => 'Various',
+    DiscTitle   => 'Cartoon Classics',
+    Offsets     => $disc_info->{offsets},   # array reference
+    TrackTitles => $disc_info->{ttitles},   # array reference
+    From        => 'login at host.domain.etc', # will try to determine
+  );
 
 =head1 DESCRIPTION
 
@@ -1227,21 +1227,21 @@
 In scalar context, calculate_id() returns just the cddbp ID.  In a
 list context, it returns an array containing the following values:
 
-	(
-		$cddbp_id,
-		$track_numbers,
-		$track_lengths,
-		$track_offsets,
-		$total_seconds
-	) = $cddbp->calculate_id(@toc);
-
-	print(
-		"cddbp ID      = $cddbp_id\n",        # b811a20c
-		"track numbers = @$track_numbers\n",  # 001 002 003 ...
-		"track lengths = @$track_lengths\n",  # 01:36 10:19 04:29 ...
-		"track offsets = @$track_offsets\n",  # 187 7367 53805 ...
-		"total seconds = $total_seconds\n",   # 4514
-	);
+  (
+    $cddbp_id,
+    $track_numbers,
+    $track_lengths,
+    $track_offsets,
+    $total_seconds
+  ) = $cddbp->calculate_id(@toc);
+
+  print(
+    "cddbp ID      = $cddbp_id\n",        # b811a20c
+    "track numbers = @$track_numbers\n",  # 001 002 003 ...
+    "track lengths = @$track_lengths\n",  # 01:36 10:19 04:29 ...
+    "track offsets = @$track_offsets\n",  # 187 7367 53805 ...
+    "total seconds = $total_seconds\n",   # 4514
+  );
 
 CDDBP_ID
 
@@ -1279,24 +1279,24 @@
 matching a given cddbp ID, track offsets, and total playing time.
 These values can be retrieved from calculade_id().
 
-	my @id_info       = $cddbp->calculate_id(@toc);
-	my $cddbp_id      = $id_info->[0];
-	my $track_offsets = $id_info->[3];
-	my $total_seconds = $id_info->[4];
+  my @id_info       = $cddbp->calculate_id(@toc);
+  my $cddbp_id      = $id_info->[0];
+  my $track_offsets = $id_info->[3];
+  my $total_seconds = $id_info->[4];
 
 get_discs() returns an array of matching discs, each of which is
 represented by an array reference.  It returns an empty array if the
 query succeeded but did not match, and it returns undef on error.
 
-	my @discs = $cddbp->get_discs( $cddbp_id, $track_offsets, $total_seconds );
-	foreach my $disc (@discs) {
-		my ($disc_genre, $disc_id, $disc_title) = @$disc;
-		print(
-			"disc id    = $disc_id\n",
-			"disc genre = $disc_genre\n",
-			"disc title = $disc_title\n",
-		);
-	}
+  my @discs = $cddbp->get_discs( $cddbp_id, $track_offsets, $total_seconds );
+  foreach my $disc (@discs) {
+    my ($disc_genre, $disc_id, $disc_title) = @$disc;
+    print(
+      "disc id    = $disc_id\n",
+      "disc genre = $disc_genre\n",
+      "disc title = $disc_title\n",
+    );
+  }
 
 DISC_GENRE is the genre this disc falls into, as determined by whoever
 submitted or last edited the disc.  The genre is required when
@@ -1325,7 +1325,7 @@
 
 Cddb protocol query strings look like:
 
-	cddb query $cddbp_id $track_count @offsets $total_seconds
+  cddb query $cddbp_id $track_count @offsets $total_seconds
 
 =item get_disc_details DISC_GENRE, CDDBP_ID
 
@@ -1337,7 +1337,7 @@
 hash.  It includes information normally stored in comments.  The most
 common entries in this hash include:
 
-	$disc_details = get_disc_details( $disc_genre, $cddbp_id );
+  $disc_details = get_disc_details( $disc_genre, $cddbp_id );
 
 $disc_details->{"disc length"}
 
@@ -1416,18 +1416,18 @@
 last set to.  It was added to fetch the default e-mail address so
 users can see it and have an opportunity to correct it.
 
-	my $mail_from = $cddb->get_mail_address();
-	print "New e-mail address (or blank to keep <$mail_from>): ";
-	my $new_mail_from = <STDIN>;
-	$new_mail_from =~ s/^\s+//;
-	$new_mail_from =~ s/\s+$//;
-	$new_mail_from =~ s/\s+/ /g;
-	$mail_from = $new_mail_from if length $new_mail_from;
-
-	$cddbp->submit_disc(
-		...,
-		From => $mail_from,
-	);
+  my $mail_from = $cddb->get_mail_address();
+  print "New e-mail address (or blank to keep <$mail_from>): ";
+  my $new_mail_from = <STDIN>;
+  $new_mail_from =~ s/^\s+//;
+  $new_mail_from =~ s/\s+$//;
+  $new_mail_from =~ s/\s+/ /g;
+  $mail_from = $new_mail_from if length $new_mail_from;
+
+  $cddbp->submit_disc(
+    ...,
+    From => $mail_from,
+  );
 
 =item get_mail_host
 
@@ -1435,18 +1435,18 @@
 to.  It was added to fetch the default e-mail transfer host so users
 can see it and have an opportunity to correct it.
 
-	my $mail_host = $cddb->get_mail_host();
-	print "New e-mail host (or blank to keep <$mail_host>): ";
-	my $new_mail_host = <STDIN>;
-	$new_mail_host =~ s/^\s+//;
-	$new_mail_host =~ s/\s+$//;
-	$new_mail_host =~ s/\s+/ /g;
-	$mail_host = $new_mail_host if length $new_mail_host;
-
-	$cddbp->submit_disc(
-		...,
-		Host => $mail_host,
-	);
+  my $mail_host = $cddb->get_mail_host();
+  print "New e-mail host (or blank to keep <$mail_host>): ";
+  my $new_mail_host = <STDIN>;
+  $new_mail_host =~ s/^\s+//;
+  $new_mail_host =~ s/\s+$//;
+  $new_mail_host =~ s/\s+/ /g;
+  $mail_host = $new_mail_host if length $new_mail_host;
+
+  $cddbp->submit_disc(
+    ...,
+    Host => $mail_host,
+  );
 
 =item parse_cdinfo CDINFO_FILE
 
@@ -1454,8 +1454,8 @@
 output of a program called "cdinfo".  CDINFO_FILE may either be a text
 file, or it may be the cdinfo program itself.
 
-	my @toc = parse_cdinfo("cdinfo.txt"); # read cdinfo.txt
-	my @toc = parse_cdinfo("cdinfo|");    # run cdinfo directly
+  my @toc = parse_cdinfo("cdinfo.txt"); # read cdinfo.txt
+  my @toc = parse_cdinfo("cdinfo|");    # run cdinfo directly
 
 The table of contents can be passed directly to calculate_id().
 
@@ -1546,19 +1546,26 @@
 Please see the cddb.t program in the t (tests) directory.  It
 exercises every aspect of CDDB.pm, including submissions.
 
-=head1 BUGS
-
-There are no known bugs, but see the README for things that need to be
-done.
+=head1 LINKS
+
+=head2 BUG TRACKER
+
+https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=CDDB
+
+=head2 REPOSITORY
+
+http://thirdlobe.com/svn/cddb/
+
+=head2 OTHER RESOURCES
+
+http://search.cpan.org/dist/CDDB/
 
 =head1 CONTACT AND COPYRIGHT
 
-Copyright 1998-2005 Rocco Caputo.  All rights reserved.  This program
+Copyright 1998-2009 Rocco Caputo.  All rights reserved.  This program
 is free software; you can redistribute it and/or modify it under the
 same terms as Perl itself.
 
-Rocco may be contacted at rcaputo at cpan.org.
-
 =cut
 
 # vim: sw=2 tw=70:

Modified: branches/upstream/libcddb-perl/current/t/01_cddb.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcddb-perl/current/t/01_cddb.t?rev=41247&op=diff
==============================================================================
--- branches/upstream/libcddb-perl/current/t/01_cddb.t (original)
+++ branches/upstream/libcddb-perl/current/t/01_cddb.t Mon Aug  3 16:42:45 2009
@@ -1,5 +1,5 @@
 #!perl -w
-# $Id: 01_cddb.t 3 2006-03-26 01:08:12Z rcaputo $
+# $Id: 01_cddb.t 6 2009-07-26 03:54:11Z rcaputo $
 # vim: filetype=perl
 # 
 # Copyright 1998-2005 Rocco Caputo <troc at netrus.net>.  All rights
@@ -8,10 +8,10 @@
 
 use strict;
 use CDDB;
+use Test::More tests => 25;
 
 BEGIN {
 	select(STDOUT); $|=1;
-	print "1..34\n";
 };
 
 my ($i, $result);
@@ -25,34 +25,18 @@
 	Debug          => 0,
 );
 
-defined($cddb) || print 'not '; print "ok 1\n";
+ok(defined($cddb), "cddb object built okay");
 
 ### test genres
 
-my @test_genres = qw(
+my @test_genres = sort qw(
 	blues classical country data folk jazz misc newage reggae rock
 	soundtrack
 );
-my @cddb_genres = $cddb->get_genres();
-
-if (@cddb_genres) {
-	print "ok 2\n";
-	if (@cddb_genres == @test_genres) {
-		print "ok 3\n";
-		@test_genres = sort @test_genres;
-		@cddb_genres = sort @cddb_genres;
-		$result = 'ok';
-		while (my $test = shift(@test_genres)) {
-			$result = 'not ok' if ($test ne shift(@cddb_genres));
-		}
-		print "$result 4\n";
-	}
-}
-else {
-	print "not ok 2\n";
-	print "not ok 3\n";
-	print "not ok 4\n";
-}
+
+my @cddb_genres = sort $cddb->get_genres();
+
+is_deeply(\@cddb_genres, \@test_genres, "got expected genres");
 
 ### helper sub: replace != tests with "not off by 5%"
 
@@ -81,8 +65,8 @@
 # Sample TOC information:
 
 my @toc = (
-	"1   0  1  71",  # track  1 starts at 00:01 and 71 frames
-	"999 5 42   4",  # leadout  starts at 05:42 and  4 frames
+	"1   0  3  71",  # track  1 starts at 00:03 and 71 frames
+	"999 5 44   4",  # leadout  starts at 05:44 and  4 frames
 );
 
 ### calculate CDDB ID
@@ -90,51 +74,16 @@
 my ($id, $track_numbers, $track_lengths, $track_offsets, $total_seconds) =
 	$cddb->calculate_id(@toc);
 
-($id ne '03015501') && print 'not '; print "ok 5\n";
-&not_near($total_seconds, 344) && print 'not '; print "ok 6\n";
+is($id, '03015501', 'calculated expected id');
+is($total_seconds, 344, 'total time matches');
 
 my @test_numbers = qw(001);
 my @test_lengths = qw(05:41);
 my @test_offsets = qw(296);
 
-if (@$track_numbers == @test_numbers) {
-	print "ok 7\n";
-	$i = 0; $result = 'ok';
-	foreach my $number (@test_numbers) {
-		$result = 'not ok' if ($number ne $track_numbers->[$i++]);
-	}
-	print "$result 8\n";
-}
-else {
-	print "not ok 7\n";
-	print "not ok 8\n";
-}
-
-if (@$track_lengths == @test_lengths) {
-	print "ok 9\n";
-	$i = 0; $result = 'ok';
-	foreach my $length (@test_lengths) {
-		$result = 'not ok' if ($length ne $track_lengths->[$i++]);
-	}
-	print "$result 10\n";
-}
-else {
-	print "not ok 9\n";
-	print "not ok 10\n";
-}
-
-if (@$track_offsets == @test_offsets) {
-	print "ok 11\n";
-	$i = 0; $result = 'ok';
-	foreach my $offset (@test_offsets) {
-		$result = 'not ok' if (&not_near($offset, $track_offsets->[$i++]));
-	}
-	print "$result 12\n";
-}
-else {
-	print "not ok 11\n";
-	print "not ok 12\n";
-}
+is_deeply($track_numbers, \@test_numbers, 'got expected track numbers');
+is_deeply($track_lengths, \@test_lengths, 'got expected track lengths');
+is_deeply($track_offsets, \@test_offsets, 'got expected track offsets');
 
 ### test looking up discs (one match)
 
@@ -142,33 +91,22 @@
 my $disc_count = @discs;
 
 my ($genre, $disc_id, $title) = @{$discs[0]};
-($disc_count == 2) || print 'not '; print "ok 13 # $disc_count\n";
-
-print "not " unless grep { $_->[0] eq "misc" } @discs;
-print "ok 14\n";
-
-($discs[0][1] eq '03015501')  || print 'not '; print "ok 15 # $discs[0][1]\n";
-
-print 'not ' unless $discs[0][2] =~ /freedb.*test/i;
-print "ok 16 # $discs[0][2]\n";
+is($disc_count, 2, 'got expected disc count');
+
+ok(scalar(grep { $_->[0] eq 'misc' } @discs), 'got expected disc genre');
+
+ok(scalar(grep { $_->[1] eq '03015501' } @discs), 'retrieved disc is expected id');
+
+#is($discs[0][1], '03015501', 'retrieved disc is expected id');
+
+like($discs[0][2], qr/freedb.*test/i, 'retrieved disc has expected title');
 
 ### test macro lookup
 
 $cddb->disconnect();
 my @other_discs = $cddb->get_discs_by_toc(@toc);
 
-if (@other_discs) {
-	my $other_count = @other_discs;
-	($other_count == 2) || print 'not '; print "ok 17 # $other_count\n";
-	($other_discs[0]->[0] eq $discs[0]->[0]) || print 'not '; print "ok 18\n";
-	($other_discs[0]->[1] eq $discs[0]->[1]) || print 'not '; print "ok 19\n";
-	($other_discs[0]->[2] eq $discs[0]->[2]) || print 'not '; print "ok 20\n";
-}
-else {
-	for (17..20) {
-		print "not ok $_ # no result\n";
-	}
-}
+is_deeply($other_discs[0], $discs[0], 'disc by toc matches disc by id');
 
 ### test gathering disc details
 
@@ -186,27 +124,10 @@
 #   }
 # }
 
-($disc_info->{'disc length'} eq '344 seconds') || print 'not ';
-print "ok 21 # $disc_info->{'disc length'}\n";
-
-($disc_info->{'discid'} eq $disc_id) || print 'not ';
-print "ok 22\n";
-
-($disc_info->{'dtitle'} eq $title) || print 'not ';
-print "ok 23\n";
-
-if (@{$disc_info->{'offsets'}} == @$track_offsets) {
-	print "ok 24\n";
-	$i = 0; $result = 'ok';
-	foreach my $offset (@{$disc_info->{'offsets'}}) {
-		$result = 'not ok' if &not_near($offset, $track_offsets->[$i++]);
-	}
-	print "$result 25\n";
-}
-else {
-	print "not ok 24\n";
-	print "not ok 25\n";
-}
+is($disc_info->{'disc length'}, '344 seconds', 'disc is expected length');
+is($disc_info->{'discid'}, $disc_id, 'disc id matches expectation');
+is($disc_info->{'dtitle'}, $title, 'disc title matches expectation');
+is_deeply($disc_info->{'offsets'}, $track_offsets, 'disc offsets match');
 
 my @test_titles = ( "01-test" );
 
@@ -219,8 +140,7 @@
 	$ok_tracks++;
 }
 
-print "not " unless $ok_tracks >= @test_titles / 2;
-print "ok 26 # $ok_tracks >= ", (@test_titles / 2), " ?\n";
+ok($ok_tracks >= @test_titles / 2, 'enough track titles match expectation');
 
 ### test fuzzy matches ("the freeside tests")
 
@@ -232,12 +152,12 @@
 );
 
 @discs = $cddb->get_discs($id, \@fuzzy_offsets, $total_seconds);
- at discs || print 'not '; print "ok 27\n";
+ok(scalar(@discs), 'retrieved at least one disc');
 
 ($genre, $disc_id, $title) = @{$discs[0]};
-(length $genre)         || print 'not '; print "ok 28\n";
-(length($disc_id) == 8) || print 'not '; print "ok 29\n";
-(length $title)         || print 'not '; print "ok 30\n";
+ok((length $genre), 'retrieved disc has a genre');
+ok((length($disc_id) == 8), 'retrieved disc id is proper length');
+ok((length $title), 'retrieved disc has a title');
 
 $id = 'c509b810';
 $total_seconds = 2488;
@@ -247,17 +167,20 @@
 );
 
 @discs = $cddb->get_discs($id, \@fuzzy_offsets, $total_seconds);
-
-if (@discs > 1) {
-	print "ok 31\n";
-}
-else {
-	print "not ok 31\n";
-}
+ok(@discs > 1, 'retrieved discs from fuzzy offset');
 
 ### test CDDB submission
-
-if ($cddb->can_submit_disc()) {
+# <bekj> dngor It's not Polite to have tests fail when things are OK,
+# Makes CPAN choke :(
+
+SKIP: {
+	unless ($cddb->can_submit_disc()) {
+		skip(
+			"Mail::Internet; Mail::Header; and MIME::QuotedPrint needed to submit",
+			1
+		);
+	}
+
 	eval {
 		$cddb->submit_disc(
 			Genre       => 'classical',
@@ -272,25 +195,15 @@
 			# odd revision for testing
 			Revision    => 123,
 		);
-		print "ok 32\n";
+
+		pass("submitted a test disc; check your e-mail for confirmation");
 	};
 
 	# skip if SMTPHOSTS and default are bad
-	if ($@ ne '') {
-		print "ok 32 # Skip - $@\n";
+	if ($@) {
+		skip($@, 1);
 	}
-}
-
-# <bekj> dngor It's not Polite to have tests fail when things are OK,
-# Makes CPAN choke :(
-
-																				# skip when needed modules are missing
-else {
-	print(
-		"ok 32 # Skip - Mail::Internet; Mail::Header; and MIME::QuotedPrint ",
-		"are needed to submit discs\n"
-	);
-}
+};
 
 ### Test fetch-by-query.
 
@@ -300,16 +213,8 @@
 );
 
 @discs = $cddb->get_discs_by_query($query);
-if (@discs) {
-	print "not " unless $discs[0][0] eq 'rock';
-	print "ok 33\n";
-	print "not " unless $discs[0][1] eq 'd30ffd0e';
-	print "ok 34\n";
-}
-else {
-	print "not ok 33\n";
-	print "not ok 34\n";
-}
+is($discs[0][0], 'rock', 'fetch-by-query retrieved expected genre');
+is($discs[0][1], 'd30ffd0e', 'fetch-by-query retrieved expected id');
 
 __END__
 




More information about the Pkg-perl-cvs-commits mailing list