From 1034da1ff657419f79977ab52bb2e9e0f7b3a413 Mon Sep 17 00:00:00 2001 From: Chad 'Exodist' Granum Date: Tue, 20 Dec 2011 15:43:57 -0800 Subject: Add feature to hide modules that may call require for you when desired. --- t/hide_middleman.t | 22 ++++++++++++++++++++++ t/hide_middleman/Bar.pm | 7 +++++++ t/hide_middleman/Foo.pm | 6 ++++++ 3 files changed, 35 insertions(+) create mode 100644 t/hide_middleman.t create mode 100644 t/hide_middleman/Bar.pm create mode 100644 t/hide_middleman/Foo.pm (limited to 't') diff --git a/t/hide_middleman.t b/t/hide_middleman.t new file mode 100644 index 0000000..d0cf652 --- /dev/null +++ b/t/hide_middleman.t @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use lib 't/hide_middleman'; +use Test::More; +use Test::Exception; + +my @warnings; +$SIG{__WARN__} = sub { push @warnings => @_ }; + +# Test passes if you comment this out +no circular::require hide => 'base'; + +use_ok( 'Foo' ); + +is_deeply( + \@warnings, + ["Circular require detected: Foo.pm (from Bar)\n"], + "Show the module that used base, instead of 'base' when a cycle occurs from a use base." +); + +done_testing; diff --git a/t/hide_middleman/Bar.pm b/t/hide_middleman/Bar.pm new file mode 100644 index 0000000..486f8dd --- /dev/null +++ b/t/hide_middleman/Bar.pm @@ -0,0 +1,7 @@ +package Bar; +use strict; +use warnings; + +use base 'Foo'; + +1; diff --git a/t/hide_middleman/Foo.pm b/t/hide_middleman/Foo.pm new file mode 100644 index 0000000..463f6ec --- /dev/null +++ b/t/hide_middleman/Foo.pm @@ -0,0 +1,6 @@ +package Foo; +use strict; +use warnings; + +use Bar; +1; -- cgit v1.2.3-54-g00ecf