From: Marius Gavrilescu Date: Sat, 11 Jun 2016 18:49:37 +0000 (+0100) Subject: Add no evil ':disable' X-Git-Tag: 0.002~2 X-Git-Url: http://git.ieval.ro/?p=acme-evil.git;a=commitdiff_plain;h=c72607e1a24d4e5172664949faf7d7abfa58b176 Add no evil ':disable' --- diff --git a/MANIFEST b/MANIFEST index 228f413..1edb770 100644 --- a/MANIFEST +++ b/MANIFEST @@ -4,9 +4,14 @@ lib/evil.pm Makefile.PL MANIFEST README +t/disable-die.t +t/disable-safe.t t/strict-die.t t/strict-safe.t t/t1/Direct.pm t/t1/Evil.pm t/t1/Indirect.pm t/t1/Unrelated.pm +t/t2/Dies.pm +t/t2/Evil.pm +t/t2/Survives.pm diff --git a/lib/evil.pm b/lib/evil.pm index db7968d..56f7824 100644 --- a/lib/evil.pm +++ b/lib/evil.pm @@ -19,8 +19,10 @@ sub import { sub unimport { my $strict_arg = grep /^:strict$/, @_; - carp 'no evil; interpreted as no evil ":strict". This will change in a future version of Acme::Evil' unless $strict_arg; - $strict = 1; # To be changed when other modes are implemented + my $disable_arg = grep /^:disable/, @_; + carp 'no evil; interpreted as no evil ":strict". This will change in a future version of Acme::Evil' unless $strict_arg || $disable_arg; + $strict = 1 unless $disable_arg; # To be changed when other modes are implemented + $strict = 0 if $disable_arg; if ($strict && %tainted) { croak "Evil module already loaded. Cannot enforce \"no evil ':strict'\""; } @@ -77,6 +79,11 @@ The calling module function properly if malignant code is loaded anywhere in the program. Throws an exception if an evil module is loaded, whether at the moment of calling this pragma or in the future. +=item no B ':disable'; + +Removes the effect of any previous C ':strict'>. In other +words evil modules will now be allowed to be loaded. + =item no B ':intermediate'; (TODO) Not yet implemented. The calling module cannot function properly if it diff --git a/t/disable-die.t b/t/disable-die.t new file mode 100644 index 0000000..0dec9bd --- /dev/null +++ b/t/disable-die.t @@ -0,0 +1,5 @@ +#!/usr/bin/perl +use Test::More tests => 1; + +ok !eval { require t::t2::Dies }, 'Unrelated dies'; + diff --git a/t/disable-safe.t b/t/disable-safe.t new file mode 100644 index 0000000..8e1473d --- /dev/null +++ b/t/disable-safe.t @@ -0,0 +1,4 @@ +#!/usr/bin/perl +use Test::More tests => 1; + +require_ok 't::t2::Survives'; diff --git a/t/t2/Dies.pm b/t/t2/Dies.pm new file mode 100644 index 0000000..7dd4f71 --- /dev/null +++ b/t/t2/Dies.pm @@ -0,0 +1,5 @@ +package t::t2::Dies; +no evil ':strict'; +no evil ':disable'; +no evil ':strict'; +use t::t2::Evil; diff --git a/t/t2/Evil.pm b/t/t2/Evil.pm new file mode 100644 index 0000000..6eaef42 --- /dev/null +++ b/t/t2/Evil.pm @@ -0,0 +1,3 @@ +package t::t2::Evil; +use evil; +1; diff --git a/t/t2/Survives.pm b/t/t2/Survives.pm new file mode 100644 index 0000000..19ece79 --- /dev/null +++ b/t/t2/Survives.pm @@ -0,0 +1,6 @@ +package t::t2::Dies; +no evil ':strict'; +no evil ':disable'; +use t::t2::Evil; + +1;