Debian lenny version packages
[pkg-perl] / deb-src / liburi-perl / liburi-perl-1.35.dfsg.1 / t / urn-isbn.t
1 #!perl -w
2
3 eval {
4     require Business::ISBN;
5 };
6 if ($@) {
7     print "1..0 # Skipped: Needs the Business::ISBN module installed\n\n";
8     print $@;
9     exit;
10 }
11
12 print "1..13\n";
13
14 use URI;
15 my $u = URI->new("URN:ISBN:0395363411");
16
17 print "not " unless $u eq "URN:ISBN:0395363411" &&
18                     $u->scheme eq "urn" &&
19                     $u->nid eq "isbn";
20 print "ok 1\n";
21
22 print "not " unless $u->canonical eq "urn:isbn:0-395-36341-1";
23 print "ok 2\n";
24
25 print "not " unless $u->isbn eq "0-395-36341-1";
26 print "ok 3\n";
27
28 print "not " unless $u->isbn_country_code == 0;
29 print "ok 4\n";
30
31 print "not " unless $u->isbn_publisher_code == 395;
32 print "ok 5\n";
33
34 print "not " unless $u->isbn_as_ean eq "9780395363416";
35 print "ok 6\n";
36
37 print "not " unless $u->nss eq "0395363411";
38 print "ok 7\n";
39
40 print "not " unless $u->isbn("0-88730-866-x") eq "0-395-36341-1";
41 print "ok 8\n";
42
43 print "not " unless $u->nss eq "0-88730-866-x";
44 print "ok 9\n";
45
46 print "not " unless $u->isbn eq "0-88730-866-X";
47 print "ok 10\n";
48
49 print "not " unless URI::eq("urn:isbn:088730866x", "URN:ISBN:0-88-73-08-66-X");
50 print "ok 11\n";
51
52 # try to illegal ones
53 $u = URI->new("urn:ISBN:abc");
54 print "not " unless $u eq "urn:ISBN:abc";
55 print "ok 12\n";
56
57 print "not " if $u->nss ne "abc" || defined $u->isbn;
58 print "ok 13\n";
59
60
61