[Bps-public-commit] r15115 - in Class-Require/trunk: t t/lib/Class/Require

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 13 06:12:20 EDT 2008


Author: sartak
Date: Wed Aug 13 06:12:20 2008
New Revision: 15115

Added:
   Class-Require/trunk/t/003-load-class.t
   Class-Require/trunk/t/lib/Class/Require/SyntaxError.pm
Modified:
   Class-Require/trunk/   (props changed)
   Class-Require/trunk/t/002-try-load-class.t

Log:
 r69464 at onn:  sartak | 2008-08-13 06:11:28 -0400
 More tests!


Modified: Class-Require/trunk/t/002-try-load-class.t
==============================================================================
--- Class-Require/trunk/t/002-try-load-class.t	(original)
+++ Class-Require/trunk/t/002-try-load-class.t	Wed Aug 13 06:12:20 2008
@@ -1,8 +1,8 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 6;
-use Class::Require 'try_load_class';
+use Test::More tests => 15;
+use Class::Require ':all';
 use lib 't/lib';
 
 ok(try_load_class('Class::Require::OK'), "loaded class OK");
@@ -14,3 +14,16 @@
 ok(try_load_class('Class::Require::OK'), "loaded class OK");
 is($Class::Require::ERROR, undef);
 
+ok(!try_load_class('Class::Require::SyntaxError'), "didn't load class SyntaxError");
+like($Class::Require::ERROR, qr{^Missing right curly or square bracket at });
+
+ok(!try_load_class('Class::Require::Nonexistent'), "didn't load class Nonexistent");
+like($Class::Require::ERROR, qr{^Can't locate Class/Require/Nonexistent.pm in \@INC});
+
+ok(!try_load_class('Class::Require::SyntaxError'), "didn't load class SyntaxError");
+like($Class::Require::ERROR, qr{^Missing right curly or square bracket at });
+
+ok(is_class_loaded('Class::Require::OK'));
+ok(!is_class_loaded('Class::Require::Nonexistent'));
+ok(!is_class_loaded('Class::Require::SyntaxError'));
+

Added: Class-Require/trunk/t/003-load-class.t
==============================================================================
--- (empty file)
+++ Class-Require/trunk/t/003-load-class.t	Wed Aug 13 06:12:20 2008
@@ -0,0 +1,38 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 15;
+use Class::Require ':all';
+use Test::Exception;
+use lib 't/lib';
+
+ok(load_class('Class::Require::OK'), "loaded class OK");
+is($Class::Require::ERROR, undef);
+
+throws_ok {
+    load_class('Class::Require::Nonexistent')
+} qr{^Can't locate Class/Require/Nonexistent.pm in \@INC};
+like($Class::Require::ERROR, qr{^Can't locate Class/Require/Nonexistent.pm in \@INC});
+
+ok(load_class('Class::Require::OK'), "loaded class OK");
+is($Class::Require::ERROR, undef);
+
+throws_ok {
+    load_class('Class::Require::SyntaxError')
+} qr{^Missing right curly or square bracket at };
+like($Class::Require::ERROR, qr{^Missing right curly or square bracket at });
+
+throws_ok {
+    load_class('Class::Require::Nonexistent')
+} qr{^Can't locate Class/Require/Nonexistent.pm in \@INC};
+like($Class::Require::ERROR, qr{^Can't locate Class/Require/Nonexistent.pm in \@INC});
+
+throws_ok {
+    load_class('Class::Require::SyntaxError')
+} qr{^Missing right curly or square bracket at };
+like($Class::Require::ERROR, qr{^Missing right curly or square bracket at });
+
+ok(is_class_loaded('Class::Require::OK'));
+ok(!is_class_loaded('Class::Require::Nonexistent'));
+ok(!is_class_loaded('Class::Require::SyntaxError'));
+

Added: Class-Require/trunk/t/lib/Class/Require/SyntaxError.pm
==============================================================================
--- (empty file)
+++ Class-Require/trunk/t/lib/Class/Require/SyntaxError.pm	Wed Aug 13 06:12:20 2008
@@ -0,0 +1,7 @@
+#!/usr/bin/env perl
+package Class::Require::SyntaxError;
+use strict;
+use warnings;
+
+sub {
+



More information about the Bps-public-commit mailing list