From 165c041256819af6c7aafba8f13b8cf7d2c80407 Mon Sep 17 00:00:00 2001 From: "Davis W. Frank" Date: Sun, 28 Jun 2009 13:35:52 -0700 Subject: [PATCH] dwf: more docs; also, previous commit refactored spies for better documentation --- doc/files.html | 6 +- doc/index.html | 2 +- doc/symbols/_global_.html | 206 +--------------------- doc/symbols/jasmine.ActionCollection.html | 2 +- doc/symbols/jasmine.NestedResults.html | 2 +- doc/symbols/jasmine.QueuedFunction.html | 2 +- doc/symbols/jasmine.Runner.html | 2 +- doc/symbols/jasmine.Spy.html | 2 +- doc/symbols/jasmine.Suite.html | 2 +- doc/symbols/jasmine.html | 39 +++- doc/symbols/jasmine.util.html | 2 +- doc/symbols/src/src_mock-timeout.js.html | 166 +++++++++++++++++ 12 files changed, 216 insertions(+), 217 deletions(-) create mode 100644 doc/symbols/src/src_mock-timeout.js.html diff --git a/doc/files.html b/doc/files.html index cb01d0c..997edb9 100644 --- a/doc/files.html +++ b/doc/files.html @@ -247,7 +247,7 @@ ul.inheritsList
-

src/jsUnitMockTimeout.js

+

src/Matchers.js

@@ -259,7 +259,7 @@ ul.inheritsList
-

src/Matchers.js

+

src/mock-timeout.js

@@ -370,7 +370,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:06 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index c6eb9b7..3f9122f 100644 --- a/doc/index.html +++ b/doc/index.html @@ -268,7 +268,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:06 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index 1c93049..9945918 100644 --- a/doc/symbols/_global_.html +++ b/doc/symbols/_global_.html @@ -266,24 +266,6 @@ ul.inheritsList - -   - -
clearInterval(timeoutKey) -
-
- - - - -   - -
clearTimeout(timeoutKey) -
-
- - -   @@ -320,24 +302,6 @@ ul.inheritsList - -   - -
setInterval(funcToCall, millis) -
-
- - - - -   - -
setTimeout(funcToCall, millis) -
-
- - -   @@ -484,84 +448,6 @@ Used for spec setup, including validating assumptions. -
- - -
- - - clearInterval(timeoutKey) - -
-
- - -
- Defined in: jsUnitMockTimeout.js. - - -
- - - - -
-
Parameters:
- -
- timeoutKey - -
-
- -
- - - - - - - - -
- - -
- - - clearTimeout(timeoutKey) - -
-
- - -
- Defined in: jsUnitMockTimeout.js. - - -
- - - - -
-
Parameters:
- -
- timeoutKey - -
-
- -
- - - - - - - -
@@ -751,96 +637,6 @@ jasmine.Matchers functions. -
- - -
- - - setInterval(funcToCall, millis) - -
-
- - -
- Defined in: jsUnitMockTimeout.js. - - -
- - - - -
-
Parameters:
- -
- funcToCall - -
-
- -
- millis - -
-
- -
- - - - - - - - -
- - -
- - - setTimeout(funcToCall, millis) - -
-
- - -
- Defined in: jsUnitMockTimeout.js. - - -
- - - - -
-
Parameters:
- -
- funcToCall - -
-
- -
- millis - -
-
- -
- - - - - - - -
@@ -1104,7 +900,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:05 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.ActionCollection.html b/doc/symbols/jasmine.ActionCollection.html index 2ae2944..3a3920c 100644 --- a/doc/symbols/jasmine.ActionCollection.html +++ b/doc/symbols/jasmine.ActionCollection.html @@ -527,7 +527,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:05 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index 90c73cd..4246ea8 100644 --- a/doc/symbols/jasmine.NestedResults.html +++ b/doc/symbols/jasmine.NestedResults.html @@ -692,7 +692,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:06 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.QueuedFunction.html b/doc/symbols/jasmine.QueuedFunction.html index 5b45ba4..0c5f0e8 100644 --- a/doc/symbols/jasmine.QueuedFunction.html +++ b/doc/symbols/jasmine.QueuedFunction.html @@ -513,7 +513,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:06 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index 34049a5..4e68965 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -410,7 +410,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:06 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index 197fa42..c928f68 100644 --- a/doc/symbols/jasmine.Spy.html +++ b/doc/symbols/jasmine.Spy.html @@ -837,7 +837,7 @@ expect(foo.bar.callCount).toEqual(0);
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:06 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index 3cdf17e..22ecbbb 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -552,7 +552,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:06 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index 9d1351a..92cd1ed 100644 --- a/doc/symbols/jasmine.html +++ b/doc/symbols/jasmine.html @@ -321,6 +321,15 @@ ul.inheritsList + + <static>   + +
jasmine.FakeTimer() +
+
+ + + <static>   @@ -670,6 +679,34 @@ large in one call. +
+ + +
<static> + + + jasmine.FakeTimer() + +
+
+ + +
+ Defined in: mock-timeout.js. + + +
+ + + + + + + + + + +
@@ -1070,7 +1107,7 @@ Jasmine environment.
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:05 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index d0b1300..10cea8e 100644 --- a/doc/symbols/jasmine.util.html +++ b/doc/symbols/jasmine.util.html @@ -466,7 +466,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:23:39 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.3.0 on Sun Jun 28 2009 13:34:06 GMT-0700 (PDT)
diff --git a/doc/symbols/src/src_mock-timeout.js.html b/doc/symbols/src/src_mock-timeout.js.html new file mode 100644 index 0000000..9a087a5 --- /dev/null +++ b/doc/symbols/src/src_mock-timeout.js.html @@ -0,0 +1,166 @@ +
  1 // Mock setTimeout, clearTimeout
+  2 // Contributed by Pivotal Computer Systems, www.pivotalsf.com
+  3 
+  4 jasmine.FakeTimer = function() {
+  5   this.reset();
+  6 
+  7   var self = this;
+  8   self.setTimeout = function(funcToCall, millis) {
+  9     self.timeoutsMade++;
+ 10     self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
+ 11     return self.timeoutsMade;
+ 12   };
+ 13 
+ 14   self.setInterval = function(funcToCall, millis) {
+ 15     self.timeoutsMade++;
+ 16     self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
+ 17     return self.timeoutsMade;
+ 18   };
+ 19 
+ 20   self.clearTimeout = function(timeoutKey) {
+ 21     self.scheduledFunctions[timeoutKey] = undefined;
+ 22   };
+ 23 
+ 24   self.clearInterval = function(timeoutKey) {
+ 25     self.scheduledFunctions[timeoutKey] = undefined;
+ 26   };
+ 27 
+ 28 };
+ 29 
+ 30 jasmine.FakeTimer.prototype.reset = function() {
+ 31   this.timeoutsMade = 0;
+ 32   this.scheduledFunctions = {};
+ 33   this.nowMillis = 0;
+ 34 };
+ 35 
+ 36 jasmine.FakeTimer.prototype.tick = function(millis) {
+ 37   var oldMillis = this.nowMillis;
+ 38   var newMillis = oldMillis + millis;
+ 39   this.runFunctionsWithinRange(oldMillis, newMillis);
+ 40   this.nowMillis = newMillis;
+ 41 };
+ 42 
+ 43 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
+ 44   var scheduledFunc;
+ 45   var funcsToRun = [];
+ 46   for (var timeoutKey in this.scheduledFunctions) {
+ 47     scheduledFunc = this.scheduledFunctions[timeoutKey];
+ 48     if (scheduledFunc != undefined &&
+ 49         scheduledFunc.runAtMillis >= oldMillis &&
+ 50         scheduledFunc.runAtMillis <= nowMillis) {
+ 51       funcsToRun.push(scheduledFunc);
+ 52       this.scheduledFunctions[timeoutKey] = undefined;
+ 53     }
+ 54   }
+ 55 
+ 56   if (funcsToRun.length > 0) {
+ 57     funcsToRun.sort(function(a, b) {
+ 58       return a.runAtMillis - b.runAtMillis;
+ 59     });
+ 60     for (var i = 0; i < funcsToRun.length; ++i) {
+ 61       try {
+ 62         var funcToRun = funcsToRun[i];
+ 63         this.nowMillis = funcToRun.runAtMillis;
+ 64         funcToRun.funcToCall();
+ 65         if (funcToRun.recurring) {
+ 66           this.scheduleFunction(funcToRun.timeoutKey,
+ 67             funcToRun.funcToCall,
+ 68             funcToRun.millis,
+ 69             true);
+ 70         }
+ 71       } catch(e) {
+ 72       }
+ 73     }
+ 74     this.runFunctionsWithinRange(oldMillis, nowMillis);
+ 75   }
+ 76 };
+ 77 
+ 78 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
+ 79   this.scheduledFunctions[timeoutKey] = {
+ 80     runAtMillis: this.nowMillis + millis,
+ 81     funcToCall: funcToCall,
+ 82     recurring: recurring,
+ 83     timeoutKey: timeoutKey,
+ 84     millis: millis
+ 85   };
+ 86 };
+ 87 
+ 88 
+ 89 jasmine.Clock = {
+ 90   defaultFakeTimer: new jasmine.FakeTimer(),
+ 91 
+ 92   reset: function() {
+ 93     jasmine.Clock.assertInstalled();
+ 94     jasmine.Clock.defaultFakeTimer.reset();
+ 95   },
+ 96 
+ 97   tick: function(millis) {
+ 98     jasmine.Clock.assertInstalled();
+ 99     jasmine.Clock.defaultFakeTimer.tick(millis);
+100   },
+101 
+102   runFunctionsWithinRange: function(oldMillis, nowMillis) {
+103     jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
+104   },
+105 
+106   scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
+107     jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
+108   },
+109 
+110   useMock: function() {
+111     var spec = jasmine.getEnv().currentSpec;
+112     spec.after(jasmine.Clock.uninstallMock);
+113 
+114     jasmine.Clock.installMock();
+115   },
+116 
+117   installMock: function() {
+118     jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
+119   },
+120 
+121   uninstallMock: function() {
+122     jasmine.Clock.assertInstalled();
+123     jasmine.Clock.installed = jasmine.Clock.real;
+124   },
+125 
+126   real: {
+127     setTimeout: window.setTimeout,
+128     clearTimeout: window.clearTimeout,
+129     setInterval: window.setInterval,
+130     clearInterval: window.clearInterval
+131   },
+132 
+133   assertInstalled: function() {
+134     if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) {
+135       throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
+136     }
+137   },  
+138 
+139   installed: null
+140 };
+141 jasmine.Clock.installed = jasmine.Clock.real;
+142 
+143 window.setTimeout = function(funcToCall, millis) {
+144   return jasmine.Clock.installed.setTimeout.apply(this, arguments);
+145 };
+146 
+147 window.setInterval = function(funcToCall, millis) {
+148   return jasmine.Clock.installed.setInterval.apply(this, arguments);
+149 };
+150 
+151 window.clearTimeout = function(timeoutKey) {
+152   return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
+153 };
+154 
+155 window.clearInterval = function(timeoutKey) {
+156   return jasmine.Clock.installed.clearInterval.apply(this, arguments);
+157 };
+158 
+159 
\ No newline at end of file