lib/jazrb/jasmine/jasmine-0.10.0.js in smparkes-jazrb-0.0.9 vs lib/jazrb/jasmine/jasmine-0.10.0.js in smparkes-jazrb-0.0.10

- old
+ new

@@ -11,14 +11,14 @@ jasmine.unimplementedMethod_ = function() { throw new Error("unimplemented method"); }; /** - * Large or small values here may result in slow test running & "Too much recursion" errors + * Default interval for event loop yields. Small values here may result in slow test running. Zero means no updates until all tests have completed. * */ -jasmine.UPDATE_INTERVAL = 250; +jasmine.DEFAULT_UPDATE_INTERVAL = 250; /** * Allows for bound functions to be comapred. Internal use only. * * @ignore @@ -58,11 +58,12 @@ /** @deprecated */ this.details = params.details; this.message = this.passed_ ? 'Passed.' : params.message; - this.trace = this.passed_ ? '' : new Error(this.message); + this.trace = this.passed_ ? '' : + ( params.exception ? params.exception : new Error(this.message) ); }; jasmine.ExpectationResult.prototype.passed = function () { return this.passed_; }; @@ -175,11 +176,11 @@ /** * Is this Object a spy? */ this.isSpy = true; /** - * The acutal function this spy stubs. + * The actual function this spy stubs. */ this.plan = function() { }; /** * Tracking of the most recent call to the spy. @@ -356,12 +357,12 @@ * @see jasmine.createSpy * @param obj * @param methodName * @returns a Jasmine spy that can be chained with all spy methods */ -var spyOn = function(obj, methodName) { - return jasmine.getEnv().currentSpec.spyOn(obj, methodName); +var spyOn = function(obj, methodName, ignore) { + return jasmine.getEnv().currentSpec.spyOn(obj, methodName, ignore); }; /** * Creates a Jasmine spec that will be added to the current suite. * @@ -418,10 +419,22 @@ */ var waits = function(timeout) { jasmine.getEnv().currentSpec.waits(timeout); }; +var anticipate = function(number) { + jasmine.getEnv().currentSpec.anticipate(number); +}; + +var incomplete = function() { + jasmine.getEnv().currentSpec.stop(); +}; + +var complete = function() { + jasmine.getEnv().currentSpec.start(); +}; + /** * Waits for the latchFunction to return true before proceeding to the next runs()-defined block. * * @param {Number} timeout * @param {Function} latchFunction @@ -537,25 +550,28 @@ jasmine.version_= { "major": 0, "minor": 10, "build": 0, - "revision": 1257815655 + "revision": 1258603168 }; /** * @namespace */ jasmine.util = {}; /** - * Declare that a child class inherite it's prototype from the parent class. + * Declare that a child class inherit it's prototype from the parent class. * * @private * @param {Function} childClass * @param {Function} parentClass */ jasmine.util.inherit = function(childClass, parentClass) { + /** + * @private + */ var subclass = function() { }; subclass.prototype = parentClass.prototype; childClass.prototype = new subclass; }; @@ -615,11 +631,11 @@ this.currentSuite = null; this.currentRunner_ = new jasmine.Runner(this); this.reporter = new jasmine.MultiReporter(); - this.updateInterval = jasmine.UPDATE_INTERVAL + this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL this.lastUpdate = 0; this.specFilter = function() { return true; }; @@ -901,11 +917,11 @@ jasmine.JsApiReporter.prototype.suites = function() { return this.suites_; }; jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { - var isSuite = suiteOrSpec instanceof jasmine.Suite + var isSuite = suiteOrSpec instanceof jasmine.Suite; var summary = { id: suiteOrSpec.id, name: suiteOrSpec.description, type: isSuite ? 'suite' : 'spec', children: [] @@ -982,11 +998,11 @@ /** * @constructor * @param {jasmine.Env} env * @param actual - * @param {jasmine.NestedResults} results + * @param {jasmine.Spec} spec */ jasmine.Matchers = function(env, actual, spec) { this.env = env; this.actual = actual; this.spec = spec; @@ -1603,10 +1619,11 @@ this.env = env; this.blocks = []; this.running = false; this.index = 0; this.offset = 0; + this._stopped = 0; }; jasmine.Queue.prototype.addBefore = function(block) { this.blocks.unshift(block); }; @@ -1624,21 +1641,34 @@ this.running = true; this.onComplete = onComplete; this.next_(); }; +jasmine.Queue.prototype._start = function() { + var self = this; + this._stopped--; + if(this._stopped == 0){ + setTimeout(function(){self.next_();},0); + } +}; + +jasmine.Queue.prototype._stop = function() { + this._stopped++; +}; + jasmine.Queue.prototype.isRunning = function() { return this.running; }; jasmine.Queue.LOOP_DONT_RECURSE = true; jasmine.Queue.prototype.next_ = function() { var self = this; var goAgain = true; - while (goAgain) { + // debug("stopped",this._stopped,self.index,self.blocks.length); + while (goAgain && this._stopped <= 0) { goAgain = false; if (self.index < self.blocks.length) { var calledSynchronously = true; var completedSynchronously = false; @@ -1647,10 +1677,13 @@ if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) { completedSynchronously = true; return; } + if( self.blocks[self.index]._anticipate !== undefined ) { + } + self.offset = 0; self.index++; var now = new Date().getTime(); if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) { @@ -1691,17 +1724,27 @@ } return results; }; -/* JasmineReporters.reporter +/** JasmineReporters.reporter * Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to * descendants of this object to do something with the results (see json_reporter.js) + * + * @deprecated */ jasmine.Reporters = {}; +/** + * @deprecated + * @param callbacks + */ jasmine.Reporters.reporter = function(callbacks) { + /** + * @deprecated + * @param callbacks + */ var that = { callbacks: callbacks || {}, doCallback: function(callback, results) { if (callback) { @@ -1856,10 +1899,22 @@ } else { this.queue.add(block); } }; +jasmine.Spec.prototype.stop = function(){ + this.queue._stop(); +} + +jasmine.Spec.prototype.start = function(){ + this.queue._start(); +} + +jasmine.Spec.prototype.anticipate = function(number){ + this._anticipate = number; +} + jasmine.Spec.prototype.addMatcherResult = function(result) { this.results_.addResult(result); }; jasmine.Spec.prototype.expect = function(actual) { @@ -1879,11 +1934,12 @@ }; jasmine.Spec.prototype.fail = function (e) { var expectationResult = new jasmine.ExpectationResult({ passed: false, - message: e ? jasmine.util.formatException(e) : 'Exception' + message: e ? jasmine.util.formatException(e) : 'Exception', + exception: e }); this.results_.addResult(expectationResult); }; jasmine.Spec.prototype.getMatchersClass_ = function() { @@ -2207,10 +2263,12 @@ timeoutKey: timeoutKey, millis: millis }; }; - +/** + * @namespace + */ jasmine.Clock = { defaultFakeTimer: new jasmine.FakeTimer(), reset: function() { jasmine.Clock.assertInstalled();