Add no evil ':disable'
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 11 Jun 2016 18:49:37 +0000 (19:49 +0100)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 11 Jun 2016 18:49:37 +0000 (19:49 +0100)
MANIFEST
lib/evil.pm
t/disable-die.t [new file with mode: 0644]
t/disable-safe.t [new file with mode: 0644]
t/t2/Dies.pm [new file with mode: 0644]
t/t2/Evil.pm [new file with mode: 0644]
t/t2/Survives.pm [new file with mode: 0644]

index 228f4135665b7dc64a67f33c0b8b50517672d301..1edb770ba0e0563c4b182053fa526cd65ce29e86 100644 (file)
--- 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
index db7968d102edd2ca1f1275b9ba522d966366dc0d..56f782470024dbb4f96fc105c7a44ed09285c1d2 100644 (file)
@@ -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<evil> ':disable';
+
+Removes the effect of any previous C<no B<evil> ':strict'>. In other
+words evil modules will now be allowed to be loaded.
+
 =item no B<evil> ':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 (file)
index 0000000..0dec9bd
--- /dev/null
@@ -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 (file)
index 0000000..8e1473d
--- /dev/null
@@ -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 (file)
index 0000000..7dd4f71
--- /dev/null
@@ -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 (file)
index 0000000..6eaef42
--- /dev/null
@@ -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 (file)
index 0000000..19ece79
--- /dev/null
@@ -0,0 +1,6 @@
+package t::t2::Dies;
+no evil ':strict';
+no evil ':disable';
+use t::t2::Evil;
+
+1;
This page took 0.012941 seconds and 4 git commands to generate.