changeset 21:cd5faa0bb46c

Added more tests for unwrap()/getWrapper().
author Atul Varma <varmaa@toolness.com>
date Mon, 22 Jun 2009 08:31:23 -0700
parents 802ab1d478c6
children 96312690f35f
files tcb.js
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tcb.js	Mon Jun 22 08:29:14 2009 -0700
+++ b/tcb.js	Mon Jun 22 08:31:23 2009 -0700
@@ -70,8 +70,17 @@
 var wrappee = {};
 var wrapped = wrap(wrappee, wrapper);
 
-if (unwrap(wrapped) !== wrappee)
+if (unwrap({}) !== null)
+  throw new Error("Unwrapping a non-wrapped object should return null!");
+
+if (getWrapper({}) !== null)
+  throw new Error("Getting the wrapper of a non-wrapped object should " +
+                  "return null!");
+
+if (unwrap(wrapped) !== wrappee ||
+    unwrap(unwrap(wrapped)) !== null)
   throw new Error("Unwrapping doesn't work!");
 
-if (getWrapper(wrapped) !== wrapper)
+if (getWrapper(wrapped) !== wrapper ||
+    getWrapper(getWrapper(wrapped)) !== null)
   throw new Error("Getting the wrapper doesn't work!");