diff core-javascript/tutorial.js @ 115:d99695cdd230 core-javascript

Finish code for transient-bind.
author jf3243
date Wed, 26 Oct 2011 17:45:18 +0100
parents e39c9c3aa96e
children 31a94b4c8687
line wrap: on
line diff
--- a/core-javascript/tutorial.js	Wed Oct 26 17:33:12 2011 +0100
+++ b/core-javascript/tutorial.js	Wed Oct 26 17:45:18 2011 +0100
@@ -88,6 +88,22 @@
 // start transient-bind
 TEST('transient-bind', function()
 {
+    // Set up the test object.
+    var return_this = function(){
+        return this;
+    };
+    var obj = {
+        return_this : return_this
+    };
+
+    // Deferring method call changes the outcome.
+    var method_deferred = obj.return_this;
+    assert( method_deferred ===  obj.return_this );
+    assert( method_deferred() !==  obj.return_this() );
+
+    // The two outcomes, precisely stated.
+    assert( obj.return_this() === obj );
+    assert( method_deferred().telltail === 'global' );
 
 });
 // end transient-bind