summaryrefslogtreecommitdiffstats
path: root/t/basic.t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-12-19 14:06:16 -0600
committerJesse Luehrs <doy@tozt.net>2011-12-19 14:06:16 -0600
commit9cc8c0a89e3984a04758240a76940bb70f49f256 (patch)
tree4298a84ceb953be8fd71b3b1c3c7b5e2d75051f3 /t/basic.t
parentb76fddd60aa8331c90c5b3cbe16f3c7685c5f4da (diff)
downloadcircular-require-9cc8c0a89e3984a04758240a76940bb70f49f256.tar.gz
circular-require-9cc8c0a89e3984a04758240a76940bb70f49f256.zip
remove test numbers
Diffstat (limited to 't/basic.t')
-rw-r--r--t/basic.t70
1 files changed, 70 insertions, 0 deletions
diff --git a/t/basic.t b/t/basic.t
new file mode 100644
index 0000000..62d92f5
--- /dev/null
+++ b/t/basic.t
@@ -0,0 +1,70 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use lib 't/basic';
+use Test::More;
+
+use circular::require ();
+
+circular::require->unimport;
+
+{
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ use_ok('Foo');
+ is($warnings, "Circular require detected: Foo.pm (from Baz)\nCircular require detected: Baz.pm (from Bar)\n", "correct warnings");
+ clear();
+}
+
+{
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ use_ok('Bar');
+ is($warnings, "Circular require detected: Baz.pm (from Foo)\nCircular require detected: Bar.pm (from Baz)\n", "correct warnings");
+ clear();
+}
+
+{
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ use_ok('Baz');
+ is($warnings, "Circular require detected: Baz.pm (from Foo)\n", "correct warnings");
+ clear();
+}
+
+circular::require->import;
+
+{
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ use_ok('Foo');
+ is($warnings, undef, "correct warnings");
+ clear();
+}
+
+{
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ use_ok('Bar');
+ is($warnings, undef, "correct warnings");
+ clear();
+}
+
+{
+ my $warnings;
+ local $SIG{__WARN__} = sub { $warnings .= $_[0] };
+ use_ok('Baz');
+ is($warnings, undef, "correct warnings");
+ clear();
+}
+
+sub clear {
+ for (qw(Foo Bar Baz)) {
+ no strict 'refs';
+ delete $::{$_};
+ delete ${$_ . '::'}{quux};
+ delete $INC{"$_.pm"};
+ }
+}
+
+done_testing;