Permalink
Browse files

[t/spec] Tests for out-of-order unwrapping and making sure re-unwrapp…

…ing and unwrapping something never wrapped dies.

git-svn-id: http://svn.pugscode.org/pugs@26154 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent a3ec362 commit 19afa8a07313a656877b22b7971eb0912860a655 jnthn committed Apr 9, 2009
Showing with 15 additions and 1 deletion.
  1. +15 −1 S06-advanced_subroutine_features/wrap.t
@@ -11,7 +11,7 @@ use Test;
# mutating wraps -- those should be "deep", as in not touching coderefs
# but actually mutating how the coderef works.
-plan 16;
+plan 21;
my @log;
@@ -34,6 +34,8 @@ foo();
is(+@log, 1, "one event logged");
is(@log[0], "foo", "it's foo");
+dies_ok { &foo.unwrap() }, 'cannot upwrap a never-wrapped sub.';
+
@log = ();
wrapper();
@@ -76,3 +78,15 @@ foo();
is(+@log, 1, "one events for unwrapped (should be back to original now)");
is(@log[0], "foo", "got execpted value");
+
+@log = ();
+
+$wrapped = &foo.wrap(&wrapper);
+$doublywrapped = &foo.wrap(&other_wrapper);
+&foo.unwrap($wrapped);
+foo();
+is(+@log, 2, "out of order unwrapping gave right number of results");
+is(@log[0], "wrapper2", "got execpted value from remaining wrapper");
+is(@log[1], "foo", "got execpted value from original sub");
+
+dies_ok { &foo.unwrap($wrapped) }, "can't re-unwrap an already unwrapped sub";

0 comments on commit 19afa8a

Please sign in to comment.