vendor/jasmine/lib/jasmine-0.9.0.js in jasmine_webos-0.0.6 vs vendor/jasmine/lib/jasmine-0.9.0.js in jasmine_webos-0.0.8
- old
+ new
@@ -1,8 +1,8 @@
/**
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
- *
+ *
* @namespace
*/
var jasmine = {};
/**
@@ -11,21 +11,34 @@
jasmine.unimplementedMethod_ = function() {
throw new Error("unimplemented method");
};
/**
+ * Large or small values here may result in slow test running & "Too much recursion" errors
+ *
+ */
+jasmine.UPDATE_INTERVAL = 250;
+
+/**
* Allows for bound functions to be comapred. Internal use only.
*
* @ignore
* @private
* @param base {Object} bound 'this' for the function
* @param name {Function} function to find
*/
jasmine.bindOriginal_ = function(base, name) {
var original = base[name];
return function() {
- return original.apply(base, arguments);
+ if (original.apply) {
+ return original.apply(base, arguments);
+ } else {
+ //IE support
+ if (base == window) {
+ return window[name].apply(window, arguments);
+ }
+ }
};
};
jasmine.setTimeout = jasmine.bindOriginal_(window, 'setTimeout');
jasmine.clearTimeout = jasmine.bindOriginal_(window, 'clearTimeout');
@@ -63,14 +76,14 @@
* @param value
* @returns {Boolean}
*/
jasmine.isArray_ = function(value) {
return value &&
- typeof value === 'object' &&
- typeof value.length === 'number' &&
- typeof value.splice === 'function' &&
- !(value.propertyIsEnumerable('length'));
+ typeof value === 'object' &&
+ typeof value.length === 'number' &&
+ typeof value.splice === 'function' &&
+ !(value.propertyIsEnumerable('length'));
};
/**
* Pretty printer for expecations. Takes any object and turns it into a human-readable string.
*
@@ -115,11 +128,11 @@
*
* A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs)
* Spies are torn down at the end of every spec.
*
* Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
- *
+ *
* @example
* // a stub
* var myStub = jasmine.createSpy('myStub'); // can be used anywhere
*
* // spy example
@@ -160,11 +173,12 @@
*/
this.isSpy = true;
/**
* The acutal function this spy stubs.
*/
- this.plan = function() {};
+ this.plan = function() {
+ };
/**
* Tracking of the most recent call to the spy.
* @example
* var mySpy = jasmine.createSpy('foo');
* mySpy(1, 2);
@@ -181,20 +195,21 @@
* mySpy.mostRecentCall.args = [7, 8];
* mySpy.argsForCall[0] = [1, 2];
* mySpy.argsForCall[1] = [7, 8];
*/
this.argsForCall = [];
+ this.calls = [];
};
/**
* Tells a spy to call through to the actual implemenatation.
*
* @example
* var foo = {
* bar: function() { // do some stuff }
* }
- *
+ *
* // defining a spy on an existing property: foo.bar
* spyOn(foo, 'bar').andCallThrough();
*/
jasmine.Spy.prototype.andCallThrough = function() {
this.plan = this.originalValue;
@@ -275,35 +290,33 @@
*/
jasmine.Spy.prototype.reset = function() {
this.wasCalled = false;
this.callCount = 0;
this.argsForCall = [];
+ this.calls = [];
this.mostRecentCall = {};
};
jasmine.createSpy = function(name) {
var spyObj = function() {
spyObj.wasCalled = true;
spyObj.callCount++;
var args = jasmine.util.argsToArray(arguments);
- //spyObj.mostRecentCall = {
- // object: this,
- // args: args
- //};
spyObj.mostRecentCall.object = this;
spyObj.mostRecentCall.args = args;
spyObj.argsForCall.push(args);
+ spyObj.calls.push({object: this, args: args});
return spyObj.plan.apply(this, arguments);
};
var spy = new jasmine.Spy(name);
-
- for(var prop in spy) {
+
+ for (var prop in spy) {
spyObj[prop] = spy[prop];
}
-
+
spyObj.reset();
return spyObj;
};
@@ -403,11 +416,11 @@
jasmine.getEnv().currentSpec.waits(timeout);
};
/**
* Waits for the latchFunction to return true before proceeding to the next runs()-defined block.
- *
+ *
* @param {Number} timeout
* @param {Function} latchFunction
* @param {String} message
*/
var waitsFor = function(timeout, latchFunction, message) {
@@ -515,11 +528,11 @@
jasmine.version_= {
"major": 0,
"minor": 9,
"build": 0,
- "revision": 1254287286
+ "revision": 1255662021
};
/**
* @namespace
*/
jasmine.util = {};
@@ -589,13 +602,11 @@
this.currentRunner_ = new jasmine.Runner(this);
this.currentlyRunningTests = false;
this.reporter = new jasmine.MultiReporter();
- this.updateInterval = 0;
-
- this.updateInterval = 0;
+ this.updateInterval = jasmine.UPDATE_INTERVAL
this.lastUpdate = 0;
this.specFilter = function() {
return true;
};
@@ -1407,11 +1418,11 @@
};
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) {
if (property == '__Jasmine_been_here_before__') continue;
- fn(property, obj.__lookupGetter__(property) != null);
+ fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
}
};
jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
@@ -1477,71 +1488,86 @@
this.running = false;
this.index = 0;
this.offset = 0;
};
-jasmine.Queue.prototype.addBefore = function (block) {
+jasmine.Queue.prototype.addBefore = function(block) {
this.blocks.unshift(block);
};
jasmine.Queue.prototype.add = function(block) {
this.blocks.push(block);
};
-jasmine.Queue.prototype.insertNext = function (block) {
+jasmine.Queue.prototype.insertNext = function(block) {
this.blocks.splice((this.index + this.offset + 1), 0, block);
this.offset++;
};
jasmine.Queue.prototype.start = function(onComplete) {
- var self = this;
- self.running = true;
- self.onComplete = onComplete;
- if (self.blocks[0]) {
- self.blocks[0].execute(function () {
- self._next();
- });
- } else {
- self.finish();
- }
+ this.running = true;
+ this.onComplete = onComplete;
+ this.next_();
};
-jasmine.Queue.prototype.isRunning = function () {
+jasmine.Queue.prototype.isRunning = function() {
return this.running;
};
-jasmine.Queue.prototype._next = function () {
+jasmine.Queue.LOOP_DONT_RECURSE = true;
+
+jasmine.Queue.prototype.next_ = function() {
var self = this;
- var doNext = function () {
- self.offset = 0;
- self.index++;
+ var goAgain = true;
+
+ while (goAgain) {
+ goAgain = false;
+
if (self.index < self.blocks.length) {
- self.blocks[self.index].execute(function () {
- self._next();
- });
+ var calledSynchronously = true;
+ var completedSynchronously = false;
+
+ var onComplete = function () {
+ if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
+ completedSynchronously = true;
+ return;
+ }
+
+ self.offset = 0;
+ self.index++;
+
+ var now = new Date().getTime();
+ if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
+ self.env.lastUpdate = now;
+ self.env.setTimeout(function() {
+ self.next_();
+ }, 0);
+ } else {
+ if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
+ goAgain = true;
+ } else {
+ self.next_();
+ }
+ }
+ };
+ self.blocks[self.index].execute(onComplete);
+
+ calledSynchronously = false;
+ if (completedSynchronously) {
+ onComplete();
+ }
+
} else {
- self.finish();
+ self.running = false;
+ if (self.onComplete) {
+ self.onComplete();
+ }
}
- };
- var now = new Date().getTime();
- if (this.env.updateInterval && now - this.env.lastUpdate > this.env.updateInterval) {
- this.env.lastUpdate = now;
- this.env.setTimeout(doNext, 0);
- } else {
- doNext();
}
-
};
-jasmine.Queue.prototype.finish = function () {
- this.running = false;
- if (this.onComplete) {
- this.onComplete();
- }
-};
-
-jasmine.Queue.prototype.results = function () {
+jasmine.Queue.prototype.results = function() {
var results = new jasmine.NestedResults();
for (var i = 0; i < this.blocks.length; i++) {
if (this.blocks[i].results) {
results.addResult(this.blocks[i].results());
}
@@ -1637,11 +1663,20 @@
/** @deprecated */
jasmine.Runner.prototype.getAllSuites = function() {
return this.suites_;
};
+jasmine.Runner.prototype.specs = function () {
+ var suites = this.suites();
+ var specs = [];
+ for (var i = 0; i < suites.length; i++) {
+ specs = specs.concat(suites[i].specs());
+ }
+ return specs;
+};
+
jasmine.Runner.prototype.suites = function() {
return this.suites_;
};
jasmine.Runner.prototype.results = function() {
@@ -2126,27 +2161,44 @@
assertInstalled: function() {
if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) {
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
}
- },
+ },
installed: null
};
jasmine.Clock.installed = jasmine.Clock.real;
+//else for IE support
window.setTimeout = function(funcToCall, millis) {
- return jasmine.Clock.installed.setTimeout.apply(this, arguments);
+ if (jasmine.Clock.installed.setTimeout.apply) {
+ return jasmine.Clock.installed.setTimeout.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.setTimeout(funcToCall, millis);
+ }
};
window.setInterval = function(funcToCall, millis) {
- return jasmine.Clock.installed.setInterval.apply(this, arguments);
+ if (jasmine.Clock.installed.setInterval.apply) {
+ return jasmine.Clock.installed.setInterval.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.setInterval(funcToCall, millis);
+ }
};
window.clearTimeout = function(timeoutKey) {
- return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
+ if (jasmine.Clock.installed.clearTimeout.apply) {
+ return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.clearTimeout(timeoutKey);
+ }
};
window.clearInterval = function(timeoutKey) {
- return jasmine.Clock.installed.clearInterval.apply(this, arguments);
+ if (jasmine.Clock.installed.clearTimeout.apply) {
+ return jasmine.Clock.installed.clearInterval.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.clearInterval(timeoutKey);
+ }
};