[libcatmandu-mab2-perl] 20/35: add more tests for exceptions and warnings

Jonas Smedegaard dr at jones.dk
Fri Oct 27 17:54:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.21-1
in repository libcatmandu-mab2-perl.

commit 7848731b369fa6ecd2dc59d2c430557513b564dd
Author: Johann Rolschewski <jorol at cpan.org>
Date:   Fri Oct 13 10:11:58 2017 +0200

    add more tests for exceptions and warnings
---
 t/01-parser.t         | 29 +++++++++++++++++++----------
 t/mab2_faulty.dat     |  1 +
 t/mab2disk_faulty.dat |  3 +++
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/t/01-parser.t b/t/01-parser.t
index a27aaca..60e6f14 100644
--- a/t/01-parser.t
+++ b/t/01-parser.t
@@ -1,12 +1,16 @@
 use strict;
 use warnings;
+use Test::Exception;
 use Test::More;
 use Test::Warn;
 use utf8;
 
+use MAB2::Parser::Disk;
+use MAB2::Parser::RAW;
+use MAB2::Parser::XML;
+
 note 'MAB2::Parser::XML';
 {
-    use MAB2::Parser::XML;
     my $parser = MAB2::Parser::XML->new('./t/mab2.xml');
     isa_ok( $parser, 'MAB2::Parser::XML' );
     my $record = $parser->next();
@@ -34,7 +38,6 @@ note 'MAB2::Parser::XML';
 
 note 'MAB2::Parser::RAW';
 {
-    use MAB2::Parser::RAW;
     my $parser = MAB2::Parser::RAW->new('./t/mab2.dat');
     isa_ok( $parser, 'MAB2::Parser::RAW' );
     my $record = $parser->next();
@@ -49,20 +52,22 @@ note 'MAB2::Parser::RAW';
     ok( $parser->next()->{_id} eq '54251-9', 'next record' );
 }
 
-note 'MAB2::Parser::RAW warnings';
+note 'MAB2::Parser::RAW exeptions';
 {
+    throws_ok { MAB2::Parser::RAW->new('mab2.xxx') } qr/^file/, 'got exeption';
+}
 
-    use MAB2::Parser::RAW;
+note 'MAB2::Parser::RAW warnings';
+{
     my $parser = MAB2::Parser::RAW->new('./t/mab2_faulty.dat');
     warning_like {$parser->next()} qr/^record terminator not found/, "got warning record terminator";
     warning_like {$parser->next()} qr/^faulty record leader/, "got warning faulty leader";
-    warning_like {$parser->next()} qr/^faulty field structure/, "got warning faulty field";
+    warning_like {$parser->next()} qr/^faulty field/, "got warning faulty field";
+    warning_like {$parser->next()} qr/^faulty field structure/, "got warning faulty field structure";
 }
 
 note 'MAB2::Parser::Disk';
 {
-
-    use MAB2::Parser::Disk;
     my $parser = MAB2::Parser::Disk->new('./t/mab2disk.dat');
     isa_ok( $parser, 'MAB2::Parser::Disk' );
     my $record = $parser->next();
@@ -78,13 +83,17 @@ note 'MAB2::Parser::Disk';
 
 }
 
-note 'MAB2::Parser::Disk warnings';
+note 'MAB2::Parser::Disk exeptions';
 {
+    throws_ok { MAB2::Parser::Disk->new('mab2disk.xxx') } qr/^file/, 'got exeption';
+}
 
-    use MAB2::Parser::Disk;
+note 'MAB2::Parser::Disk warnings';
+{
     my $parser = MAB2::Parser::Disk->new('./t/mab2disk_faulty.dat');
     warning_like {$parser->next()} qr/^faulty record leader/, "got warning faulty leader";
-    warning_like {$parser->next()} qr/^faulty field structure/, "got warning faulty field";
+    warning_like {$parser->next()} qr/^faulty field/, "got warning faulty field";
+    warning_like {$parser->next()} qr/^faulty field structure/, "got warning faulty field structure";
 }
 
 done_testing;
diff --git a/t/mab2_faulty.dat b/t/mab2_faulty.dat
index cda62b5..0faafe7 100644
--- a/t/mab2_faulty.dat
+++ b/t/mab2_faulty.dat
@@ -1,3 +1,4 @@
 02020nM2.01200024      h001 47918-4

 0202XnM2.01200024      h001 47918-4


+02020nM2.01200024      h001 


 02020nM2.01200024      h001 47918-4
025#010420517


\ No newline at end of file
diff --git a/t/mab2disk_faulty.dat b/t/mab2disk_faulty.dat
index bbb5e28..70821ba 100644
--- a/t/mab2disk_faulty.dat
+++ b/t/mab2disk_faulty.dat
@@ -2,5 +2,8 @@
 001 47918-4
 
 ### 02020nM2.01200024      h
+001 
+
+### 02020nM2.01200024      h
 001 47918-4
 025#010420517

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-mab2-perl.git



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