1 /**
  2  * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
  3  *
  4  * @namespace
  5  */
  6 var jasmine = {};
  7 
  8 /**
  9  * @private
 10  */
 11 jasmine.unimplementedMethod_ = function() {
 12   throw new Error("unimplemented method");
 13 };
 14 
 15 /**
 16  * Large or small values here may result in slow test running & "Too much recursion" errors
 17  *
 18  */
 19 jasmine.UPDATE_INTERVAL = 250;
 20 
 21 /**
 22  * Allows for bound functions to be comapred.  Internal use only.
 23  *
 24  * @ignore
 25  * @private
 26  * @param base {Object} bound 'this' for the function
 27  * @param name {Function} function to find
 28  */
 29 jasmine.bindOriginal_ = function(base, name) {
 30   var original = base[name];
 31   return function() {
 32     if (original.apply) {
 33       return original.apply(base, arguments);
 34     } else {
 35       //IE support
 36       if (base == window) {
 37         return window[name].apply(window, arguments);
 38       }
 39     }
 40   };
 41 };
 42 
 43 jasmine.setTimeout = jasmine.bindOriginal_(window, 'setTimeout');
 44 jasmine.clearTimeout = jasmine.bindOriginal_(window, 'clearTimeout');
 45 jasmine.setInterval = jasmine.bindOriginal_(window, 'setInterval');
 46 jasmine.clearInterval = jasmine.bindOriginal_(window, 'clearInterval');
 47 
 48 jasmine.MessageResult = function(text) {
 49   this.type = 'MessageResult';
 50   this.text = text;
 51   this.trace = new Error(); // todo: test better
 52 };
 53 
 54 jasmine.ExpectationResult = function(params) {
 55   this.type = 'ExpectationResult';
 56   this.matcherName = params.matcherName;
 57   this.passed_ = params.passed;
 58   this.expected = params.expected;
 59   this.actual = params.actual;
 60 
 61   /** @deprecated */
 62   this.details = params.details;
 63   
 64   this.message = this.passed_ ? 'Passed.' : params.message;
 65   this.trace = this.passed_ ? '' : new Error(this.message);
 66 };
 67 
 68 jasmine.ExpectationResult.prototype.passed = function () {
 69   return this.passed_;
 70 };
 71 
 72 /**
 73  * Getter for the Jasmine environment. Ensures one gets created
 74  */
 75 jasmine.getEnv = function() {
 76   return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
 77 };
 78 
 79 /**
 80  * @ignore
 81  * @private
 82  * @param value
 83  * @returns {Boolean}
 84  */
 85 jasmine.isArray_ = function(value) {
 86   return value &&
 87          typeof value === 'object' &&
 88          typeof value.length === 'number' &&
 89          typeof value.splice === 'function' &&
 90          !(value.propertyIsEnumerable('length'));
 91 };
 92 
 93 /**
 94  * Pretty printer for expecations.  Takes any object and turns it into a human-readable string.
 95  *
 96  * @param value {Object} an object to be outputted
 97  * @returns {String}
 98  */
 99 jasmine.pp = function(value) {
100   var stringPrettyPrinter = new jasmine.StringPrettyPrinter();
101   stringPrettyPrinter.format(value);
102   return stringPrettyPrinter.string;
103 };
104 
105 /**
106  * Returns true if the object is a DOM Node.
107  *
108  * @param {Object} obj object to check
109  * @returns {Boolean}
110  */
111 jasmine.isDomNode = function(obj) {
112   return obj['nodeType'] > 0;
113 };
114 
115 /**
116  * Returns a matchable 'generic' object of the class type.  For use in expecations of type when values don't matter.
117  *
118  * @example
119  * // don't care about which function is passed in, as long as it's a function
120  * expect(mySpy).wasCalledWith(jasmine.any(Function));
121  *
122  * @param {Class} clazz
123  * @returns matchable object of the type clazz
124  */
125 jasmine.any = function(clazz) {
126   return new jasmine.Matchers.Any(clazz);
127 };
128 
129 /**
130  * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
131  *
132  * Spies should be created in test setup, before expectations.  They can then be checked, using the standard Jasmine
133  * expectation syntax. Spies can be checked if they were called or not and what the calling params were.
134  *
135  * A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs)
136  * Spies are torn down at the end of every spec.
137  *
138  * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
139  *
140  * @example
141  * // a stub
142  * var myStub = jasmine.createSpy('myStub');  // can be used anywhere
143  *
144  * // spy example
145  * var foo = {
146  *   not: function(bool) { return !bool; }
147  * }
148  *
149  * // actual foo.not will not be called, execution stops
150  * spyOn(foo, 'not');
151 
152  // foo.not spied upon, execution will continue to implementation
153  * spyOn(foo, 'not').andCallThrough();
154  *
155  * // fake example
156  * var foo = {
157  *   not: function(bool) { return !bool; }
158  * }
159  *
160  * // foo.not(val) will return val
161  * spyOn(foo, 'not').andCallFake(function(value) {return value;});
162  *
163  * // mock example
164  * foo.not(7 == 7);
165  * expect(foo.not).wasCalled();
166  * expect(foo.not).wasCalledWith(true);
167  *
168  * @constructor
169  * @see spyOn, jasmine.createSpy, jasmine.createSpyObj
170  * @param {String} name
171  */
172 jasmine.Spy = function(name) {
173   /**
174    * The name of the spy, if provided.
175    */
176   this.identity = name || 'unknown';
177   /**
178    *  Is this Object a spy?
179    */
180   this.isSpy = true;
181   /**
182    * The acutal function this spy stubs.
183    */
184   this.plan = function() {
185   };
186   /**
187    * Tracking of the most recent call to the spy.
188    * @example
189    * var mySpy = jasmine.createSpy('foo');
190    * mySpy(1, 2);
191    * mySpy.mostRecentCall.args = [1, 2];
192    */
193   this.mostRecentCall = {};
194 
195   /**
196    * Holds arguments for each call to the spy, indexed by call count
197    * @example
198    * var mySpy = jasmine.createSpy('foo');
199    * mySpy(1, 2);
200    * mySpy(7, 8);
201    * mySpy.mostRecentCall.args = [7, 8];
202    * mySpy.argsForCall[0] = [1, 2];
203    * mySpy.argsForCall[1] = [7, 8];
204    */
205   this.argsForCall = [];
206   this.calls = [];
207 };
208 
209 /**
210  * Tells a spy to call through to the actual implemenatation.
211  *
212  * @example
213  * var foo = {
214  *   bar: function() { // do some stuff }
215  * }
216  *
217  * // defining a spy on an existing property: foo.bar
218  * spyOn(foo, 'bar').andCallThrough();
219  */
220 jasmine.Spy.prototype.andCallThrough = function() {
221   this.plan = this.originalValue;
222   return this;
223 };
224 
225 /**
226  * For setting the return value of a spy.
227  *
228  * @example
229  * // defining a spy from scratch: foo() returns 'baz'
230  * var foo = jasmine.createSpy('spy on foo').andReturn('baz');
231  *
232  * // defining a spy on an existing property: foo.bar() returns 'baz'
233  * spyOn(foo, 'bar').andReturn('baz');
234  *
235  * @param {Object} value
236  */
237 jasmine.Spy.prototype.andReturn = function(value) {
238   this.plan = function() {
239     return value;
240   };
241   return this;
242 };
243 
244 /**
245  * For throwing an exception when a spy is called.
246  *
247  * @example
248  * // defining a spy from scratch: foo() throws an exception w/ message 'ouch'
249  * var foo = jasmine.createSpy('spy on foo').andThrow('baz');
250  *
251  * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch'
252  * spyOn(foo, 'bar').andThrow('baz');
253  *
254  * @param {String} exceptionMsg
255  */
256 jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
257   this.plan = function() {
258     throw exceptionMsg;
259   };
260   return this;
261 };
262 
263 /**
264  * Calls an alternate implementation when a spy is called.
265  *
266  * @example
267  * var baz = function() {
268  *   // do some stuff, return something
269  * }
270  * // defining a spy from scratch: foo() calls the function baz
271  * var foo = jasmine.createSpy('spy on foo').andCall(baz);
272  *
273  * // defining a spy on an existing property: foo.bar() calls an anonymnous function
274  * spyOn(foo, 'bar').andCall(function() { return 'baz';} );
275  *
276  * @param {Function} fakeFunc
277  */
278 jasmine.Spy.prototype.andCallFake = function(fakeFunc) {
279   this.plan = fakeFunc;
280   return this;
281 };
282 
283 /**
284  * Resets all of a spy's the tracking variables so that it can be used again.
285  *
286  * @example
287  * spyOn(foo, 'bar');
288  *
289  * foo.bar();
290  *
291  * expect(foo.bar.callCount).toEqual(1);
292  *
293  * foo.bar.reset();
294  *
295  * expect(foo.bar.callCount).toEqual(0);
296  */
297 jasmine.Spy.prototype.reset = function() {
298   this.wasCalled = false;
299   this.callCount = 0;
300   this.argsForCall = [];
301   this.calls = [];
302   this.mostRecentCall = {};
303 };
304 
305 jasmine.createSpy = function(name) {
306 
307   var spyObj = function() {
308     spyObj.wasCalled = true;
309     spyObj.callCount++;
310     var args = jasmine.util.argsToArray(arguments);
311     spyObj.mostRecentCall.object = this;
312     spyObj.mostRecentCall.args = args;
313     spyObj.argsForCall.push(args);
314     spyObj.calls.push({object: this, args: args});
315     return spyObj.plan.apply(this, arguments);
316   };
317 
318   var spy = new jasmine.Spy(name);
319 
320   for (var prop in spy) {
321     spyObj[prop] = spy[prop];
322   }
323 
324   spyObj.reset();
325 
326   return spyObj;
327 };
328 
329 /**
330  * Creates a more complicated spy: an Object that has every property a function that is a spy.  Used for stubbing something
331  * large in one call.
332  *
333  * @param {String} baseName name of spy class
334  * @param {Array} methodNames array of names of methods to make spies
335  */
336 jasmine.createSpyObj = function(baseName, methodNames) {
337   var obj = {};
338   for (var i = 0; i < methodNames.length; i++) {
339     obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
340   }
341   return obj;
342 };
343 
344 jasmine.log = function(message) {
345   jasmine.getEnv().currentSpec.log(message);
346 };
347 
348 /**
349  * Function that installs a spy on an existing object's method name.  Used within a Spec to create a spy.
350  *
351  * @example
352  * // spy example
353  * var foo = {
354  *   not: function(bool) { return !bool; }
355  * }
356  * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops
357  *
358  * @see jasmine.createSpy
359  * @param obj
360  * @param methodName
361  * @returns a Jasmine spy that can be chained with all spy methods
362  */
363 var spyOn = function(obj, methodName) {
364   return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
365 };
366 
367 /**
368  * Creates a Jasmine spec that will be added to the current suite.
369  *
370  * // TODO: pending tests
371  *
372  * @example
373  * it('should be true', function() {
374  *   expect(true).toEqual(true);
375  * });
376  *
377  * @param {String} desc description of this specification
378  * @param {Function} func defines the preconditions and expectations of the spec
379  */
380 var it = function(desc, func) {
381   return jasmine.getEnv().it(desc, func);
382 };
383 
384 /**
385  * Creates a <em>disabled</em> Jasmine spec.
386  *
387  * A convenience method that allows existing specs to be disabled temporarily during development.
388  *
389  * @param {String} desc description of this specification
390  * @param {Function} func defines the preconditions and expectations of the spec
391  */
392 var xit = function(desc, func) {
393   return jasmine.getEnv().xit(desc, func);
394 };
395 
396 /**
397  * Starts a chain for a Jasmine expectation.
398  *
399  * It is passed an Object that is the actual value and should chain to one of the many
400  * jasmine.Matchers functions.
401  *
402  * @param {Object} actual Actual value to test against and expected value
403  */
404 var expect = function(actual) {
405   return jasmine.getEnv().currentSpec.expect(actual);
406 };
407 
408 /**
409  * Defines part of a jasmine spec.  Used in cominbination with waits or waitsFor in asynchrnous specs.
410  *
411  * @param {Function} func Function that defines part of a jasmine spec.
412  */
413 var runs = function(func) {
414   jasmine.getEnv().currentSpec.runs(func);
415 };
416 
417 /**
418  * Waits for a timeout before moving to the next runs()-defined block.
419  * @param {Number} timeout
420  */
421 var waits = function(timeout) {
422   jasmine.getEnv().currentSpec.waits(timeout);
423 };
424 
425 /**
426  * Waits for the latchFunction to return true before proceeding to the next runs()-defined block.
427  *
428  * @param {Number} timeout
429  * @param {Function} latchFunction
430  * @param {String} message
431  */
432 var waitsFor = function(timeout, latchFunction, message) {
433   jasmine.getEnv().currentSpec.waitsFor(timeout, latchFunction, message);
434 };
435 
436 /**
437  * A function that is called before each spec in a suite.
438  *
439  * Used for spec setup, including validating assumptions.
440  *
441  * @param {Function} beforeEachFunction
442  */
443 var beforeEach = function(beforeEachFunction) {
444   jasmine.getEnv().beforeEach(beforeEachFunction);
445 };
446 
447 /**
448  * A function that is called after each spec in a suite.
449  *
450  * Used for restoring any state that is hijacked during spec execution.
451  *
452  * @param {Function} afterEachFunction
453  */
454 var afterEach = function(afterEachFunction) {
455   jasmine.getEnv().afterEach(afterEachFunction);
456 };
457 
458 /**
459  * Defines a suite of specifications.
460  *
461  * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
462  * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
463  * of setup in some tests.
464  *
465  * @example
466  * // TODO: a simple suite
467  *
468  * // TODO: a simple suite with a nested describe block
469  *
470  * @param {String} description A string, usually the class under test.
471  * @param {Function} specDefinitions function that defines several specs.
472  */
473 var describe = function(description, specDefinitions) {
474   return jasmine.getEnv().describe(description, specDefinitions);
475 };
476 
477 /**
478  * Disables a suite of specifications.  Used to disable some suites in a file, or files, temporarily during development.
479  *
480  * @param {String} description A string, usually the class under test.
481  * @param {Function} specDefinitions function that defines several specs.
482  */
483 var xdescribe = function(description, specDefinitions) {
484   return jasmine.getEnv().xdescribe(description, specDefinitions);
485 };
486 
487 
488 jasmine.XmlHttpRequest = XMLHttpRequest;
489 
490 // Provide the XMLHttpRequest class for IE 5.x-6.x:
491 if (typeof XMLHttpRequest == "undefined") jasmine.XmlHttpRequest = function() {
492   try {
493     return new ActiveXObject("Msxml2.XMLHTTP.6.0");
494   } catch(e) {
495   }
496   try {
497     return new ActiveXObject("Msxml2.XMLHTTP.3.0");
498   } catch(e) {
499   }
500   try {
501     return new ActiveXObject("Msxml2.XMLHTTP");
502   } catch(e) {
503   }
504   try {
505     return new ActiveXObject("Microsoft.XMLHTTP");
506   } catch(e) {
507   }
508   throw new Error("This browser does not support XMLHttpRequest.");
509 };
510 
511 /**
512  * Adds suite files to an HTML document so that they are executed, thus adding them to the current
513  * Jasmine environment.
514  *
515  * @param {String} url path to the file to include
516  * @param {Boolean} opt_global
517  */
518 jasmine.include = function(url, opt_global) {
519   if (opt_global) {
520     document.write('<script type="text/javascript" src="' + url + '"></' + 'script>');
521   } else {
522     var xhr;
523     try {
524       xhr = new jasmine.XmlHttpRequest();
525       xhr.open("GET", url, false);
526       xhr.send(null);
527     } catch(e) {
528       throw new Error("couldn't fetch " + url + ": " + e);
529     }
530 
531     return eval(xhr.responseText);
532   }
533 };
534 
535 jasmine.version_= {
536   "major": 0,
537   "minor": 10,
538   "build": 0,
539   "revision": 1256870671
540   };
541 /**
542  * @namespace
543  */
544 jasmine.util = {};
545 
546 /**
547  * Declare that a child class inherite it's prototype from the parent class.
548  *
549  * @private
550  * @param {Function} childClass
551  * @param {Function} parentClass
552  */
553 jasmine.util.inherit = function(childClass, parentClass) {
554   var subclass = function() {
555   };
556   subclass.prototype = parentClass.prototype;
557   childClass.prototype = new subclass;
558 };
559 
560 jasmine.util.formatException = function(e) {
561   var lineNumber;
562   if (e.line) {
563     lineNumber = e.line;
564   }
565   else if (e.lineNumber) {
566     lineNumber = e.lineNumber;
567   }
568 
569   var file;
570 
571   if (e.sourceURL) {
572     file = e.sourceURL;
573   }
574   else if (e.fileName) {
575     file = e.fileName;
576   }
577 
578   var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
579 
580   if (file && lineNumber) {
581     message += ' in ' + file + ' (line ' + lineNumber + ')';
582   }
583 
584   return message;
585 };
586 
587 jasmine.util.htmlEscape = function(str) {
588   if (!str) return str;
589   return str.replace(/&/g, '&')
590     .replace(/</g, '<')
591     .replace(/>/g, '>');
592 };
593 
594 jasmine.util.argsToArray = function(args) {
595   var arrayOfArgs = [];
596   for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
597   return arrayOfArgs;
598 };
599 
600 jasmine.util.extend = function(destination, source) {
601   for (var property in source) destination[property] = source[property];
602   return destination;
603 };
604 
605 /**
606  * Environment for Jasmine
607  *
608  * @constructor
609  */
610 jasmine.Env = function() {
611   this.currentSpec = null;
612   this.currentSuite = null;
613   this.currentRunner_ = new jasmine.Runner(this);
614 
615   this.reporter = new jasmine.MultiReporter();
616 
617   this.updateInterval = jasmine.UPDATE_INTERVAL
618   this.lastUpdate = 0;
619   this.specFilter = function() {
620     return true;
621   };
622 
623   this.nextSpecId_ = 0;
624   this.nextSuiteId_ = 0;
625   this.equalityTesters_ = [];
626 };
627 
628 
629 jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
630 jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
631 jasmine.Env.prototype.setInterval = jasmine.setInterval;
632 jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
633 
634 /**
635  * @returns an object containing jasmine version build info, if set.
636  */
637 jasmine.Env.prototype.version = function () {
638   if (jasmine.version_) {
639     return jasmine.version_;
640   } else {
641     throw new Error('Version not set');
642   }
643 };
644 
645 /**
646  * @returns a sequential integer starting at 0
647  */
648 jasmine.Env.prototype.nextSpecId = function () {
649   return this.nextSpecId_++;
650 };
651 
652 /**
653  * @returns a sequential integer starting at 0
654  */
655 jasmine.Env.prototype.nextSuiteId = function () {
656   return this.nextSuiteId_++;
657 };
658 
659 /**
660  * Register a reporter to receive status updates from Jasmine.
661  * @param {jasmine.Reporter} reporter An object which will receive status updates.
662  */
663 jasmine.Env.prototype.addReporter = function(reporter) {
664   this.reporter.addReporter(reporter);
665 };
666 
667 jasmine.Env.prototype.execute = function() {
668   this.currentRunner_.execute();
669 };
670 
671 jasmine.Env.prototype.describe = function(description, specDefinitions) {
672   var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
673 
674   var parentSuite = this.currentSuite;
675   if (parentSuite) {
676     parentSuite.add(suite);
677   } else {
678     this.currentRunner_.add(suite);
679   }
680 
681   this.currentSuite = suite;
682 
683   specDefinitions.call(suite);
684 
685   this.currentSuite = parentSuite;
686 
687   return suite;
688 };
689 
690 jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
691   if (this.currentSuite) {
692     this.currentSuite.beforeEach(beforeEachFunction);
693   } else {
694     this.currentRunner_.beforeEach(beforeEachFunction);
695   }
696 };
697 
698 jasmine.Env.prototype.currentRunner = function () {
699   return this.currentRunner_;
700 };
701 
702 jasmine.Env.prototype.afterEach = function(afterEachFunction) {
703   if (this.currentSuite) {
704     this.currentSuite.afterEach(afterEachFunction);
705   } else {
706     this.currentRunner_.afterEach(afterEachFunction);
707   }
708 
709 };
710 
711 jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
712   return {
713     execute: function() {
714     }
715   };
716 };
717 
718 jasmine.Env.prototype.it = function(description, func) {
719   var spec = new jasmine.Spec(this, this.currentSuite, description);
720   this.currentSuite.add(spec);
721   this.currentSpec = spec;
722 
723   if (func) {
724     spec.runs(func);
725   }
726 
727   return spec;
728 };
729 
730 jasmine.Env.prototype.xit = function(desc, func) {
731   return {
732     id: this.nextSpecId(),
733     runs: function() {
734     }
735   };
736 };
737 
738 jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
739   if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
740     return true;
741   }
742 
743   a.__Jasmine_been_here_before__ = b;
744   b.__Jasmine_been_here_before__ = a;
745 
746   var hasKey = function(obj, keyName) {
747     return obj != null && obj[keyName] !== undefined;
748   };
749 
750   for (var property in b) {
751     if (!hasKey(a, property) && hasKey(b, property)) {
752       mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
753     }
754   }
755   for (property in a) {
756     if (!hasKey(b, property) && hasKey(a, property)) {
757       mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
758     }
759   }
760   for (property in b) {
761     if (property == '__Jasmine_been_here_before__') continue;
762     if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
763       mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
764     }
765   }
766 
767   if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
768     mismatchValues.push("arrays were not the same length");
769   }
770 
771   delete a.__Jasmine_been_here_before__;
772   delete b.__Jasmine_been_here_before__;
773   return (mismatchKeys.length == 0 && mismatchValues.length == 0);
774 };
775 
776 jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
777   mismatchKeys = mismatchKeys || [];
778   mismatchValues = mismatchValues || [];
779 
780   if (a === b) return true;
781 
782   if (a === undefined || a === null || b === undefined || b === null) {
783     return (a == undefined && b == undefined);
784   }
785 
786   if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
787     return a === b;
788   }
789 
790   if (a instanceof Date && b instanceof Date) {
791     return a.getTime() == b.getTime();
792   }
793 
794   if (a instanceof jasmine.Matchers.Any) {
795     return a.matches(b);
796   }
797 
798   if (b instanceof jasmine.Matchers.Any) {
799     return b.matches(a);
800   }
801 
802   if (typeof a === "object" && typeof b === "object") {
803     return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
804   }
805 
806   for (var i = 0; i < this.equalityTesters_.length; i++) {
807     var equalityTester = this.equalityTesters_[i];
808     var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
809     if (result !== undefined) return result;
810   }
811 
812   //Straight check
813   return (a === b);
814 };
815 
816 jasmine.Env.prototype.contains_ = function(haystack, needle) {
817   if (jasmine.isArray_(haystack)) {
818     for (var i = 0; i < haystack.length; i++) {
819       if (this.equals_(haystack[i], needle)) return true;
820     }
821     return false;
822   }
823   return haystack.indexOf(needle) >= 0;
824 };
825 
826 jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
827   this.equalityTesters_.push(equalityTester);
828 };
829 /** No-op base class for Jasmine reporters.
830  *
831  * @constructor
832  */
833 jasmine.Reporter = function() {
834 };
835 
836 //noinspection JSUnusedLocalSymbols
837 jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
838 };
839 
840 //noinspection JSUnusedLocalSymbols
841 jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
842 };
843 
844 //noinspection JSUnusedLocalSymbols
845 jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
846 };
847 
848 //noinspection JSUnusedLocalSymbols
849 jasmine.Reporter.prototype.reportSpecResults = function(spec) {
850 };
851 
852 //noinspection JSUnusedLocalSymbols
853 jasmine.Reporter.prototype.log = function(str) {
854 };
855 
856 /**
857  * Blocks are functions with executable code that make up a spec.
858  *
859  * @constructor
860  * @param {jasmine.Env} env
861  * @param {Function} func
862  * @param {jasmine.Spec} spec
863  */
864 jasmine.Block = function(env, func, spec) {
865   this.env = env;
866   this.func = func;
867   this.spec = spec;
868 };
869 
870 jasmine.Block.prototype.execute = function(onComplete) {  
871   try {
872     this.func.apply(this.spec);
873   } catch (e) {
874     this.spec.fail(e);
875   }
876   onComplete();
877 };
878 /** JavaScript API reporter.
879  *
880  * @constructor
881  */
882 jasmine.JsApiReporter = function() {
883   this.started = false;
884   this.finished = false;
885   this.suites_ = [];
886   this.results_ = {};
887 };
888 
889 jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
890   this.started = true;
891   var suites = runner.suites();
892   for (var i = 0; i < suites.length; i++) {
893     var suite = suites[i];
894     this.suites_.push(this.summarize_(suite));
895   }
896 };
897 
898 jasmine.JsApiReporter.prototype.suites = function() {
899   return this.suites_;
900 };
901 
902 jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
903   var isSuite = suiteOrSpec instanceof jasmine.Suite
904   var summary = {
905     id: suiteOrSpec.id,
906     name: suiteOrSpec.description,
907     type: isSuite ? 'suite' : 'spec',
908     children: []
909   };
910   if (isSuite) {
911     var specs = suiteOrSpec.specs();
912     for (var i = 0; i < specs.length; i++) {
913       summary.children.push(this.summarize_(specs[i]));
914     }
915   }
916   return summary;
917 };
918 
919 jasmine.JsApiReporter.prototype.results = function() {
920   return this.results_;
921 };
922 
923 jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
924   return this.results_[specId];
925 };
926 
927 //noinspection JSUnusedLocalSymbols
928 jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
929   this.finished = true;
930 };
931 
932 //noinspection JSUnusedLocalSymbols
933 jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
934 };
935 
936 //noinspection JSUnusedLocalSymbols
937 jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
938   this.results_[spec.id] = {
939     messages: spec.results().getItems(),
940     result: spec.results().failedCount > 0 ? "failed" : "passed"
941   };
942 };
943 
944 //noinspection JSUnusedLocalSymbols
945 jasmine.JsApiReporter.prototype.log = function(str) {
946 };
947 
948 jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
949   var results = {};
950   for (var i = 0; i < specIds.length; i++) {
951     var specId = specIds[i];
952     results[specId] = this.summarizeResult_(this.results_[specId]);
953   }
954   return results;
955 };
956 
957 jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
958   var summaryMessages = [];
959   for (var messageIndex in result.messages) {
960     var resultMessage = result.messages[messageIndex];
961     summaryMessages.push({
962       text: resultMessage.text,
963       passed: resultMessage.passed ? resultMessage.passed() : true,
964       type: resultMessage.type,
965       message: resultMessage.message,
966       trace: {
967         stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : undefined
968       }
969     });
970   };
971 
972   var summaryResult = {
973     result : result.result,
974     messages : summaryMessages
975   };
976 
977   return summaryResult;
978 };
979 
980 /**
981  * @constructor
982  * @param {jasmine.Env} env
983  * @param actual
984  * @param {jasmine.NestedResults} results
985  */
986 jasmine.Matchers = function(env, actual, spec) {
987   this.env = env;
988   this.actual = actual;
989   this.spec = spec;
990 };
991 
992 jasmine.Matchers.pp = function(str) {
993   return jasmine.util.htmlEscape(jasmine.pp(str));
994 };
995 
996 jasmine.Matchers.prototype.report = function(result, failing_message, details) {
997   var expectationResult = new jasmine.ExpectationResult({
998     passed: result,
999     message: failing_message,
1000     details: details
1001   });
1002   this.spec.addMatcherResult(expectationResult);
1003   return result;
1004 };
1005 
1006 /**
1007  * Matcher that compares the actual to the expected using ===.
1008  *
1009  * @param expected
1010  */
1011 
1012 
1013 jasmine.Matchers.addMatcher = function(matcherName, options) {
1014   jasmine.Matchers.prototype[matcherName] = function () {
1015     jasmine.util.extend(this, options);
1016     var expected = jasmine.util.argsToArray(arguments);
1017     var args = [this.actual].concat(expected);
1018     var result = options.test.apply(this, args);
1019     var message;
1020     if (!result) {
1021       message = options.message.apply(this, args);
1022     }
1023     var expectationResult = new jasmine.ExpectationResult({
1024       matcherName: matcherName,
1025       passed: result,
1026       expected: expected,
1027       actual: this.actual,
1028       message: message
1029     });
1030     this.spec.addMatcherResult(expectationResult);
1031     return result;
1032   };
1033 };
1034 
1035 
1036 /**
1037  * toBe: compares the actual to the expected using ===
1038  * @param expected
1039  */
1040 
1041 jasmine.Matchers.addMatcher('toBe', {
1042   test: function (actual, expected) {
1043     return actual === expected;
1044   },
1045   message: function(actual, expected) {
1046     return "Expected " + jasmine.pp(actual) + " to be " + jasmine.pp(expected);
1047   }
1048 });
1049 
1050 /**
1051  * toNotBe: compares the actual to the expected using !==
1052  * @param expected
1053  */
1054 jasmine.Matchers.addMatcher('toNotBe', {
1055   test: function (actual, expected) {
1056     return actual !== expected;
1057   },
1058   message: function(actual, expected) {
1059     return "Expected " + jasmine.pp(actual) + " to not be " + jasmine.pp(expected);
1060   }
1061 });
1062 
1063 /**
1064  * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
1065  *
1066  * @param expected
1067  */
1068 
1069 jasmine.Matchers.addMatcher('toEqual', {
1070   test: function (actual, expected) {
1071     return this.env.equals_(actual, expected);
1072   },
1073   message: function(actual, expected) {
1074     return "Expected " + jasmine.pp(actual) + " to equal " + jasmine.pp(expected);
1075   }
1076 });
1077 
1078 /**
1079  * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
1080  * @param expected
1081  */
1082 jasmine.Matchers.addMatcher('toNotEqual', {
1083   test: function (actual, expected) {
1084     return !this.env.equals_(actual, expected);
1085   },
1086   message: function(actual, expected) {
1087     return "Expected " + jasmine.pp(actual) + " to not equal " + jasmine.pp(expected);
1088   }
1089 });
1090 
1091 /**
1092  * Matcher that compares the actual to the expected using a regular expression.  Constructs a RegExp, so takes
1093  * a pattern or a String.
1094  *
1095  * @param reg_exp
1096  */
1097 jasmine.Matchers.addMatcher('toMatch', {
1098   test: function(actual, expected) {
1099     return new RegExp(expected).test(actual);
1100   },
1101   message: function(actual, expected) {
1102     return actual + " does not match the regular expression " + new RegExp(expected).toString();
1103   }
1104 });
1105 
1106 /**
1107  * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
1108  * @param reg_exp
1109  */
1110 
1111 jasmine.Matchers.addMatcher('toNotMatch', {
1112   test: function(actual, expected) {
1113     return !(new RegExp(expected).test(actual));
1114   },
1115   message: function(actual, expected) {
1116     return actual + " should not match " + new RegExp(expected).toString();
1117   }
1118 });
1119 
1120 /**
1121  * Matcher that compares the acutal to undefined.
1122  */
1123 
1124 jasmine.Matchers.addMatcher('toBeDefined', {
1125   test: function(actual) {
1126     return (actual !== undefined);
1127   },
1128   message: function() {
1129     return 'Expected actual to not be undefined.';
1130   }
1131 });
1132 
1133 /**
1134  * Matcher that compares the acutal to undefined.
1135  */
1136 
1137 jasmine.Matchers.addMatcher('toBeUndefined', {
1138   test: function(actual) {
1139     return (actual === undefined);
1140   },
1141   message: function(actual) {
1142     return 'Expected ' + jasmine.pp(actual) + ' to be undefined.';
1143   }
1144 });
1145 
1146 /**
1147  * Matcher that compares the actual to null.
1148  *
1149  */
1150 jasmine.Matchers.addMatcher('toBeNull', {
1151   test: function(actual) {
1152     return (actual === null);
1153   },
1154   message: function(actual) {
1155     return 'Expected ' + jasmine.pp(actual) + ' to be null.';
1156   }
1157 });
1158 
1159 /**
1160  * Matcher that boolean not-nots the actual.
1161  */
1162 jasmine.Matchers.addMatcher('toBeTruthy', {
1163   test: function(actual) {
1164     return !!actual;
1165   },
1166   message: function() {
1167     return 'Expected actual to be truthy';
1168   }
1169 });
1170 
1171 
1172 /**
1173  * Matcher that boolean nots the actual.
1174  */
1175 jasmine.Matchers.addMatcher('toBeFalsy', {
1176   test: function(actual) {
1177     return !actual;
1178   },
1179   message: function(actual) {
1180     return 'Expected ' + jasmine.pp(actual) + ' to be falsy';
1181   }
1182 });
1183 
1184 /**
1185  * Matcher that checks to see if the acutal, a Jasmine spy, was called.
1186  */
1187 
1188 jasmine.Matchers.addMatcher('wasCalled', {
1189   getActual_: function() {
1190     var args = jasmine.util.argsToArray(arguments);
1191     if (args.length > 1) {
1192       throw(new Error('wasCalled does not take arguments, use wasCalledWith'));
1193     }
1194     return args.splice(0, 1)[0];
1195   },
1196   test: function() {
1197     var actual = this.getActual_.apply(this, arguments);
1198     if (!actual || !actual.isSpy) {
1199       return false;
1200     }
1201     return actual.wasCalled;
1202   },
1203   message: function() {
1204     var actual = this.getActual_.apply(this, arguments);
1205     if (!actual || !actual.isSpy) {
1206       return 'Actual is not a spy.';
1207     }
1208     return "Expected spy " + actual.identity + " to have been called.";
1209   }
1210 });
1211 
1212 /**
1213  * Matcher that checks to see if the acutal, a Jasmine spy, was not called.
1214  */
1215 jasmine.Matchers.addMatcher('wasNotCalled', {
1216   getActual_: function() {
1217     var args = jasmine.util.argsToArray(arguments);
1218     return args.splice(0, 1)[0];
1219   },
1220   test: function() {
1221     var actual = this.getActual_.apply(this, arguments);
1222     if (!actual || !actual.isSpy) {
1223       return false;
1224     }
1225     return !actual.wasCalled;
1226   },
1227   message: function() {
1228     var actual = this.getActual_.apply(this, arguments);
1229     if (!actual || !actual.isSpy) {
1230       return 'Actual is not a spy.';
1231     }
1232     return "Expected spy " + actual.identity + " to not have been called.";
1233   }
1234 });
1235 
1236 jasmine.Matchers.addMatcher('wasCalledWith', {
1237   test: function() {
1238     var args = jasmine.util.argsToArray(arguments);
1239     var actual = args.splice(0, 1)[0];
1240     if (!actual || !actual.isSpy) {
1241       return false;
1242     }
1243     return this.env.contains_(actual.argsForCall, args);
1244   },
1245   message: function() {
1246     var args = jasmine.util.argsToArray(arguments);
1247     var actual = args.splice(0, 1)[0];
1248     var message;
1249     if (!actual || !actual.isSpy) {
1250       message = 'Actual is not a spy';
1251     } else {
1252       message = "Expected spy to have been called with " + jasmine.pp(args) + " but was called with " + actual.argsForCall;
1253     }
1254     return message;
1255   }
1256 });
1257 
1258 /**
1259  * Matcher that checks to see if the acutal, a Jasmine spy, was called with a set of parameters.
1260  *
1261  * @example
1262  *
1263  */
1264 
1265 /**
1266  * Matcher that checks that the expected item is an element in the actual Array.
1267  *
1268  * @param {Object} item
1269  */
1270 
1271 jasmine.Matchers.addMatcher('toContain', {
1272   test: function(actual, expected) {
1273     return this.env.contains_(actual, expected);
1274   },
1275   message: function(actual, expected) {
1276     return 'Expected ' + jasmine.pp(actual) + ' to contain ' + jasmine.pp(expected);
1277   }
1278 });
1279 
1280 /**
1281  * Matcher that checks that the expected item is NOT an element in the actual Array.
1282  *
1283  * @param {Object} item
1284  */
1285 jasmine.Matchers.addMatcher('toNotContain', {
1286   test: function(actual, expected) {
1287     return !this.env.contains_(actual, expected);
1288   },
1289   message: function(actual, expected) {
1290     return 'Expected ' + jasmine.pp(actual) + ' to not contain ' + jasmine.pp(expected);
1291   }
1292 });
1293 
1294 jasmine.Matchers.addMatcher('toBeLessThan', {
1295   test: function(actual, expected) {
1296     return actual < expected;
1297   },
1298   message: function(actual, expected) {
1299     return 'Expected ' + jasmine.pp(actual) + ' to be less than ' + jasmine.pp(expected);
1300   }
1301 });
1302 
1303 jasmine.Matchers.addMatcher('toBeGreaterThan', {
1304   test: function(actual, expected) {
1305     return actual > expected;
1306   },
1307   message: function(actual, expected) {
1308     return 'Expected ' + jasmine.pp(actual) + ' to be greater than ' + jasmine.pp(expected);
1309   }
1310 });
1311 
1312 /**
1313  * Matcher that checks that the expected exception was thrown by the actual.
1314  *
1315  * @param {String} expectedException
1316  */
1317 jasmine.Matchers.addMatcher('toThrow', {
1318   getException_: function(actual, expected) {
1319     var exception;
1320     if (typeof actual != 'function') {
1321       throw new Error('Actual is not a function');
1322     }
1323     try {
1324       actual();
1325     } catch (e) {
1326       exception = e;
1327     }
1328     return exception;
1329   },
1330   test: function(actual, expected) {
1331     var result = false;
1332     var exception = this.getException_(actual, expected);
1333     if (exception) {
1334       result = (expected === undefined || this.env.equals_(exception.message || exception, expected.message || expected));
1335     }
1336     return result;
1337   },
1338   message: function(actual, expected) {
1339     var exception = this.getException_(actual, expected);
1340     if (exception && (expected === undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
1341       return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception  ].join(' ');
1342     } else {
1343       return "Expected function to throw an exception.";
1344     }
1345   }
1346 });
1347 
1348 jasmine.Matchers.Any = function(expectedClass) {
1349   this.expectedClass = expectedClass;
1350 };
1351 
1352 jasmine.Matchers.Any.prototype.matches = function(other) {
1353   if (this.expectedClass == String) {
1354     return typeof other == 'string' || other instanceof String;
1355   }
1356 
1357   if (this.expectedClass == Number) {
1358     return typeof other == 'number' || other instanceof Number;
1359   }
1360 
1361   if (this.expectedClass == Function) {
1362     return typeof other == 'function' || other instanceof Function;
1363   }
1364 
1365   if (this.expectedClass == Object) {
1366     return typeof other == 'object';
1367   }
1368 
1369   return other instanceof this.expectedClass;
1370 };
1371 
1372 jasmine.Matchers.Any.prototype.toString = function() {
1373   return '<jasmine.any(' + this.expectedClass + ')>';
1374 };
1375 
1376 /**
1377  * @constructor
1378  */
1379 jasmine.MultiReporter = function() {
1380   this.subReporters_ = [];
1381 };
1382 jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
1383 
1384 jasmine.MultiReporter.prototype.addReporter = function(reporter) {
1385   this.subReporters_.push(reporter);
1386 };
1387 
1388 (function() {
1389   var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"];
1390   for (var i = 0; i < functionNames.length; i++) {
1391     var functionName = functionNames[i];
1392     jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
1393       return function() {
1394         for (var j = 0; j < this.subReporters_.length; j++) {
1395           var subReporter = this.subReporters_[j];
1396           if (subReporter[functionName]) {
1397             subReporter[functionName].apply(subReporter, arguments);
1398           }
1399         }
1400       };
1401     })(functionName);
1402   }
1403 })();
1404 /**
1405  * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
1406  *
1407  * @constructor
1408  */
1409 jasmine.NestedResults = function() {
1410   /**
1411    * The total count of results
1412    */
1413   this.totalCount = 0;
1414   /**
1415    * Number of passed results
1416    */
1417   this.passedCount = 0;
1418   /**
1419    * Number of failed results
1420    */
1421   this.failedCount = 0;
1422   /**
1423    * Was this suite/spec skipped?
1424    */
1425   this.skipped = false;
1426   /**
1427    * @ignore
1428    */
1429   this.items_ = [];
1430 };
1431 
1432 /**
1433  * Roll up the result counts.
1434  *
1435  * @param result
1436  */
1437 jasmine.NestedResults.prototype.rollupCounts = function(result) {
1438   this.totalCount += result.totalCount;
1439   this.passedCount += result.passedCount;
1440   this.failedCount += result.failedCount;
1441 };
1442 
1443 /**
1444  * Tracks a result's message.
1445  * @param message
1446  */
1447 jasmine.NestedResults.prototype.log = function(message) {
1448   this.items_.push(new jasmine.MessageResult(message));
1449 };
1450 
1451 /**
1452  * Getter for the results: message & results.
1453  */
1454 jasmine.NestedResults.prototype.getItems = function() {
1455   return this.items_;
1456 };
1457 
1458 /**
1459  * Adds a result, tracking counts (total, passed, & failed)
1460  * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
1461  */
1462 jasmine.NestedResults.prototype.addResult = function(result) {
1463   if (result.type != 'MessageResult') {
1464     if (result.items_) {
1465       this.rollupCounts(result);
1466     } else {
1467       this.totalCount++;
1468       if (result.passed()) {
1469         this.passedCount++;
1470       } else {
1471         this.failedCount++;
1472       }
1473     }
1474   }
1475   this.items_.push(result);
1476 };
1477 
1478 /**
1479  * @returns {Boolean} True if <b>everything</b> below passed
1480  */
1481 jasmine.NestedResults.prototype.passed = function() {
1482   return this.passedCount === this.totalCount;
1483 };
1484 /**
1485  * Base class for pretty printing for expectation results.
1486  */
1487 jasmine.PrettyPrinter = function() {
1488   this.ppNestLevel_ = 0;
1489 };
1490 
1491 /**
1492  * Formats a value in a nice, human-readable string.
1493  *
1494  * @param value
1495  * @returns {String}
1496  */
1497 jasmine.PrettyPrinter.prototype.format = function(value) {
1498   if (this.ppNestLevel_ > 40) {
1499     //    return '(jasmine.pp nested too deeply!)';
1500     throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
1501   }
1502 
1503   this.ppNestLevel_++;
1504   try {
1505     if (value === undefined) {
1506       this.emitScalar('undefined');
1507     } else if (value === null) {
1508       this.emitScalar('null');
1509     } else if (value.navigator && value.frames && value.setTimeout) {
1510       this.emitScalar('<window>');
1511     } else if (value instanceof jasmine.Matchers.Any) {
1512       this.emitScalar(value.toString());
1513     } else if (typeof value === 'string') {
1514       this.emitString(value);
1515     } else if (typeof value === 'function') {
1516       this.emitScalar('Function');
1517     } else if (typeof value.nodeType === 'number') {
1518       this.emitScalar('HTMLNode');
1519     } else if (value instanceof Date) {
1520       this.emitScalar('Date(' + value + ')');
1521     } else if (value.__Jasmine_been_here_before__) {
1522       this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
1523     } else if (jasmine.isArray_(value) || typeof value == 'object') {
1524       value.__Jasmine_been_here_before__ = true;
1525       if (jasmine.isArray_(value)) {
1526         this.emitArray(value);
1527       } else {
1528         this.emitObject(value);
1529       }
1530       delete value.__Jasmine_been_here_before__;
1531     } else {
1532       this.emitScalar(value.toString());
1533     }
1534   } finally {
1535     this.ppNestLevel_--;
1536   }
1537 };
1538 
1539 jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1540   for (var property in obj) {
1541     if (property == '__Jasmine_been_here_before__') continue;
1542     fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false);
1543   }
1544 };
1545 
1546 jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
1547 jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
1548 jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
1549 jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
1550 
1551 jasmine.StringPrettyPrinter = function() {
1552   jasmine.PrettyPrinter.call(this);
1553 
1554   this.string = '';
1555 };
1556 jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
1557 
1558 jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
1559   this.append(value);
1560 };
1561 
1562 jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
1563   this.append("'" + value + "'");
1564 };
1565 
1566 jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
1567   this.append('[ ');
1568   for (var i = 0; i < array.length; i++) {
1569     if (i > 0) {
1570       this.append(', ');
1571     }
1572     this.format(array[i]);
1573   }
1574   this.append(' ]');
1575 };
1576 
1577 jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
1578   var self = this;
1579   this.append('{ ');
1580   var first = true;
1581 
1582   this.iterateObject(obj, function(property, isGetter) {
1583     if (first) {
1584       first = false;
1585     } else {
1586       self.append(', ');
1587     }
1588 
1589     self.append(property);
1590     self.append(' : ');
1591     if (isGetter) {
1592       self.append('<getter>');
1593     } else {
1594       self.format(obj[property]);
1595     }
1596   });
1597 
1598   this.append(' }');
1599 };
1600 
1601 jasmine.StringPrettyPrinter.prototype.append = function(value) {
1602   this.string += value;
1603 };
1604 jasmine.Queue = function(env) {
1605   this.env = env;
1606   this.blocks = [];
1607   this.running = false;
1608   this.index = 0;
1609   this.offset = 0;
1610 };
1611 
1612 jasmine.Queue.prototype.addBefore = function(block) {
1613   this.blocks.unshift(block);
1614 };
1615 
1616 jasmine.Queue.prototype.add = function(block) {
1617   this.blocks.push(block);
1618 };
1619 
1620 jasmine.Queue.prototype.insertNext = function(block) {
1621   this.blocks.splice((this.index + this.offset + 1), 0, block);
1622   this.offset++;
1623 };
1624 
1625 jasmine.Queue.prototype.start = function(onComplete) {
1626   this.running = true;
1627   this.onComplete = onComplete;
1628   this.next_();
1629 };
1630 
1631 jasmine.Queue.prototype.isRunning = function() {
1632   return this.running;
1633 };
1634 
1635 jasmine.Queue.LOOP_DONT_RECURSE = true;
1636 
1637 jasmine.Queue.prototype.next_ = function() {
1638   var self = this;
1639   var goAgain = true;
1640 
1641   while (goAgain) {
1642     goAgain = false;
1643     
1644     if (self.index < self.blocks.length) {
1645       var calledSynchronously = true;
1646       var completedSynchronously = false;
1647 
1648       var onComplete = function () {
1649         if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
1650           completedSynchronously = true;
1651           return;
1652         }
1653 
1654         self.offset = 0;
1655         self.index++;
1656 
1657         var now = new Date().getTime();
1658         if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
1659           self.env.lastUpdate = now;
1660           self.env.setTimeout(function() {
1661             self.next_();
1662           }, 0);
1663         } else {
1664           if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
1665             goAgain = true;
1666           } else {
1667             self.next_();
1668           }
1669         }
1670       };
1671       self.blocks[self.index].execute(onComplete);
1672 
1673       calledSynchronously = false;
1674       if (completedSynchronously) {
1675         onComplete();
1676       }
1677       
1678     } else {
1679       self.running = false;
1680       if (self.onComplete) {
1681         self.onComplete();
1682       }
1683     }
1684   }
1685 };
1686 
1687 jasmine.Queue.prototype.results = function() {
1688   var results = new jasmine.NestedResults();
1689   for (var i = 0; i < this.blocks.length; i++) {
1690     if (this.blocks[i].results) {
1691       results.addResult(this.blocks[i].results());
1692     }
1693   }
1694   return results;
1695 };
1696 
1697 
1698 /* JasmineReporters.reporter
1699  *    Base object that will get called whenever a Spec, Suite, or Runner is done.  It is up to
1700  *    descendants of this object to do something with the results (see json_reporter.js)
1701  */
1702 jasmine.Reporters = {};
1703 
1704 jasmine.Reporters.reporter = function(callbacks) {
1705   var that = {
1706     callbacks: callbacks || {},
1707 
1708     doCallback: function(callback, results) {
1709       if (callback) {
1710         callback(results);
1711       }
1712     },
1713 
1714     reportRunnerResults: function(runner) {
1715       that.doCallback(that.callbacks.runnerCallback, runner);
1716     },
1717     reportSuiteResults:  function(suite) {
1718       that.doCallback(that.callbacks.suiteCallback, suite);
1719     },
1720     reportSpecResults:   function(spec) {
1721       that.doCallback(that.callbacks.specCallback, spec);
1722     },
1723     log: function (str) {
1724       if (console && console.log) console.log(str);
1725     }
1726   };
1727 
1728   return that;
1729 };
1730 
1731 /**
1732  * Runner
1733  *
1734  * @constructor
1735  * @param {jasmine.Env} env
1736  */
1737 jasmine.Runner = function(env) {
1738   var self = this;
1739   self.env = env;
1740   self.queue = new jasmine.Queue(env);
1741   self.before_ = [];
1742   self.after_ = [];
1743   self.suites_ = [];
1744 };
1745 
1746 jasmine.Runner.prototype.execute = function() {
1747   var self = this;
1748   if (self.env.reporter.reportRunnerStarting) {
1749     self.env.reporter.reportRunnerStarting(this);
1750   }
1751   self.queue.start(function () {
1752     self.finishCallback();
1753   });
1754 };
1755 
1756 jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
1757   beforeEachFunction.typeName = 'beforeEach';
1758   this.before_.push(beforeEachFunction);
1759 };
1760 
1761 jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
1762   afterEachFunction.typeName = 'afterEach';
1763   this.after_.push(afterEachFunction);
1764 };
1765 
1766 
1767 jasmine.Runner.prototype.finishCallback = function() {
1768   this.env.reporter.reportRunnerResults(this);
1769 };
1770 
1771 jasmine.Runner.prototype.addSuite = function(suite) {
1772   this.suites_.push(suite);
1773 };
1774 
1775 jasmine.Runner.prototype.add = function(block) {
1776   if (block instanceof jasmine.Suite) {
1777     this.addSuite(block);
1778   }
1779   this.queue.add(block);
1780 };
1781 
1782 jasmine.Runner.prototype.specs = function () {
1783   var suites = this.suites();
1784   var specs = [];
1785   for (var i = 0; i < suites.length; i++) {
1786     specs = specs.concat(suites[i].specs());
1787   }
1788   return specs;
1789 };
1790 
1791 
1792 jasmine.Runner.prototype.suites = function() {
1793   return this.suites_;
1794 };
1795 
1796 jasmine.Runner.prototype.results = function() {
1797   return this.queue.results();
1798 };
1799 /**
1800  * Internal representation of a Jasmine specification, or test.
1801  *
1802  * @constructor
1803  * @param {jasmine.Env} env
1804  * @param {jasmine.Suite} suite
1805  * @param {String} description
1806  */
1807 jasmine.Spec = function(env, suite, description) {
1808   if (!env) {
1809     throw new Error('jasmine.Env() required');
1810   }
1811   ;
1812   if (!suite) {
1813     throw new Error('jasmine.Suite() required');
1814   }
1815   ;
1816   var spec = this;
1817   spec.id = env.nextSpecId ? env.nextSpecId() : null;
1818   spec.env = env;
1819   spec.suite = suite;
1820   spec.description = description;
1821   spec.queue = new jasmine.Queue(env);
1822 
1823   spec.afterCallbacks = [];
1824   spec.spies_ = [];
1825 
1826   spec.results_ = new jasmine.NestedResults();
1827   spec.results_.description = description;
1828   spec.matchersClass = null;
1829 };
1830 
1831 jasmine.Spec.prototype.getFullName = function() {
1832   return this.suite.getFullName() + ' ' + this.description + '.';
1833 };
1834 
1835 
1836 jasmine.Spec.prototype.results = function() {
1837   return this.results_;
1838 };
1839 
1840 jasmine.Spec.prototype.log = function(message) {
1841   return this.results_.log(message);
1842 };
1843 
1844 jasmine.Spec.prototype.runs = function (func) {
1845   var block = new jasmine.Block(this.env, func, this);
1846   this.addToQueue(block);
1847   return this;
1848 };
1849 
1850 jasmine.Spec.prototype.addToQueue = function (block) {
1851   if (this.queue.isRunning()) {
1852     this.queue.insertNext(block);
1853   } else {
1854     this.queue.add(block);
1855   }
1856 };
1857 
1858 jasmine.Spec.prototype.addMatcherResult = function(result) {
1859   this.results_.addResult(result);
1860 };
1861 
1862 jasmine.Spec.prototype.expect = function(actual) {
1863   return new (this.getMatchersClass_())(this.env, actual, this);
1864 };
1865 
1866 jasmine.Spec.prototype.waits = function(timeout) {
1867   var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
1868   this.addToQueue(waitsFunc);
1869   return this;
1870 };
1871 
1872 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) {
1873   var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this);
1874   this.addToQueue(waitsForFunc);
1875   return this;
1876 };
1877 
1878 jasmine.Spec.prototype.fail = function (e) {
1879   var expectationResult = new jasmine.ExpectationResult({
1880     passed: false,
1881     message: e ? jasmine.util.formatException(e) : 'Exception'
1882   });
1883   this.results_.addResult(expectationResult);
1884 };
1885 
1886 jasmine.Spec.prototype.getMatchersClass_ = function() {
1887   return this.matchersClass || jasmine.Matchers;
1888 };
1889 
1890 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
1891   var parent = this.getMatchersClass_();
1892   var newMatchersClass = function() {
1893     parent.apply(this, arguments);
1894   };
1895   jasmine.util.inherit(newMatchersClass, parent);
1896   for (var method in matchersPrototype) {
1897     newMatchersClass.prototype[method] = matchersPrototype[method];
1898   }
1899   this.matchersClass = newMatchersClass;
1900 };
1901 
1902 jasmine.Spec.prototype.finishCallback = function() {
1903   this.env.reporter.reportSpecResults(this);
1904 };
1905 
1906 jasmine.Spec.prototype.finish = function(onComplete) {
1907   this.removeAllSpies();
1908   this.finishCallback();
1909   if (onComplete) {
1910     onComplete();
1911   }
1912 };
1913 
1914 jasmine.Spec.prototype.after = function(doAfter, test) {
1915 
1916   if (this.queue.isRunning()) {
1917     this.queue.add(new jasmine.Block(this.env, doAfter, this));
1918   } else {
1919     this.afterCallbacks.unshift(doAfter);
1920   }
1921 };
1922 
1923 jasmine.Spec.prototype.execute = function(onComplete) {
1924   var spec = this;
1925   if (!spec.env.specFilter(spec)) {
1926     spec.results_.skipped = true;
1927     spec.finish(onComplete);
1928     return;
1929   }
1930   this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...');
1931 
1932   spec.env.currentSpec = spec;
1933 
1934   spec.addBeforesAndAftersToQueue();
1935 
1936   spec.queue.start(function () {
1937     spec.finish(onComplete);
1938   });
1939 };
1940 
1941 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
1942   var runner = this.env.currentRunner();
1943   for (var suite = this.suite; suite; suite = suite.parentSuite) {
1944     for (var i = 0; i < suite.before_.length; i++) {
1945       this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
1946     }
1947   }
1948   for (var i = 0; i < runner.before_.length; i++) {
1949     this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
1950   }
1951   for (i = 0; i < this.afterCallbacks.length; i++) {
1952     this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
1953   }
1954   for (suite = this.suite; suite; suite = suite.parentSuite) {
1955     for (var i = 0; i < suite.after_.length; i++) {
1956       this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
1957     }
1958   }
1959   for (var i = 0; i < runner.after_.length; i++) {
1960     this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
1961   }
1962 };
1963 
1964 jasmine.Spec.prototype.explodes = function() {
1965   throw 'explodes function should not have been called';
1966 };
1967 
1968 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
1969   if (obj == undefined) {
1970     throw "spyOn could not find an object to spy upon for " + methodName + "()";
1971   }
1972 
1973   if (!ignoreMethodDoesntExist && obj[methodName] === undefined) {
1974     throw methodName + '() method does not exist';
1975   }
1976 
1977   if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
1978     throw new Error(methodName + ' has already been spied upon');
1979   }
1980 
1981   var spyObj = jasmine.createSpy(methodName);
1982 
1983   this.spies_.push(spyObj);
1984   spyObj.baseObj = obj;
1985   spyObj.methodName = methodName;
1986   spyObj.originalValue = obj[methodName];
1987 
1988   obj[methodName] = spyObj;
1989 
1990   return spyObj;
1991 };
1992 
1993 jasmine.Spec.prototype.removeAllSpies = function() {
1994   for (var i = 0; i < this.spies_.length; i++) {
1995     var spy = this.spies_[i];
1996     spy.baseObj[spy.methodName] = spy.originalValue;
1997   }
1998   this.spies_ = [];
1999 };
2000 
2001 /**
2002  * Internal representation of a Jasmine suite.
2003  *
2004  * @constructor
2005  * @param {jasmine.Env} env
2006  * @param {String} description
2007  * @param {Function} specDefinitions
2008  * @param {jasmine.Suite} parentSuite
2009  */
2010 jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
2011   var self = this;
2012   self.id = env.nextSuiteId ? env.nextSuiteId() : null;
2013   self.description = description;
2014   self.queue = new jasmine.Queue(env);
2015   self.parentSuite = parentSuite;
2016   self.env = env;
2017   self.before_ = [];
2018   self.after_ = [];
2019   self.specs_ = [];
2020 };
2021 
2022 jasmine.Suite.prototype.getFullName = function() {
2023   var fullName = this.description;
2024   for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
2025     fullName = parentSuite.description + ' ' + fullName;
2026   }
2027   return fullName;
2028 };
2029 
2030 jasmine.Suite.prototype.finish = function(onComplete) {
2031   this.env.reporter.reportSuiteResults(this);
2032   this.finished = true;
2033   if (typeof(onComplete) == 'function') {
2034     onComplete();
2035   }
2036 };
2037 
2038 jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
2039   beforeEachFunction.typeName = 'beforeEach';
2040   this.before_.push(beforeEachFunction);
2041 };
2042 
2043 jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
2044   afterEachFunction.typeName = 'afterEach';
2045   this.after_.push(afterEachFunction);
2046 };
2047 
2048 jasmine.Suite.prototype.results = function() {
2049   return this.queue.results();
2050 };
2051 
2052 jasmine.Suite.prototype.add = function(block) {
2053   if (block instanceof jasmine.Suite) {
2054     this.env.currentRunner().addSuite(block);
2055   } else {
2056     this.specs_.push(block);
2057   }
2058   this.queue.add(block);
2059 };
2060 
2061 jasmine.Suite.prototype.specs = function() {
2062   return this.specs_;
2063 };
2064 
2065 jasmine.Suite.prototype.execute = function(onComplete) {
2066   var self = this;
2067   this.queue.start(function () {
2068     self.finish(onComplete);
2069   });
2070 };
2071 jasmine.WaitsBlock = function(env, timeout, spec) {
2072   this.timeout = timeout;
2073   jasmine.Block.call(this, env, null, spec);
2074 };
2075 
2076 jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
2077 
2078 jasmine.WaitsBlock.prototype.execute = function (onComplete) {
2079   this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
2080   this.env.setTimeout(function () {
2081     onComplete();
2082   }, this.timeout);
2083 };
2084 jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
2085   this.timeout = timeout;
2086   this.latchFunction = latchFunction;
2087   this.message = message;
2088   this.totalTimeSpentWaitingForLatch = 0;
2089   jasmine.Block.call(this, env, null, spec);
2090 };
2091 
2092 jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
2093 
2094 jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100;
2095 
2096 jasmine.WaitsForBlock.prototype.execute = function (onComplete) {
2097   var self = this;
2098   self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen'));
2099   var latchFunctionResult;
2100   try {
2101     latchFunctionResult = self.latchFunction.apply(self.spec);
2102   } catch (e) {
2103     self.spec.fail(e);
2104     onComplete();
2105     return;
2106   }
2107 
2108   if (latchFunctionResult) {
2109     onComplete();
2110   } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) {
2111     var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen');
2112     self.spec.fail({
2113       name: 'timeout',
2114       message: message
2115     });
2116     self.spec._next();
2117   } else {
2118     self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
2119     self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
2120   }
2121 };
2122 // Mock setTimeout, clearTimeout
2123 // Contributed by Pivotal Computer Systems, www.pivotalsf.com
2124 
2125 jasmine.FakeTimer = function() {
2126   this.reset();
2127 
2128   var self = this;
2129   self.setTimeout = function(funcToCall, millis) {
2130     self.timeoutsMade++;
2131     self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
2132     return self.timeoutsMade;
2133   };
2134 
2135   self.setInterval = function(funcToCall, millis) {
2136     self.timeoutsMade++;
2137     self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
2138     return self.timeoutsMade;
2139   };
2140 
2141   self.clearTimeout = function(timeoutKey) {
2142     self.scheduledFunctions[timeoutKey] = undefined;
2143   };
2144 
2145   self.clearInterval = function(timeoutKey) {
2146     self.scheduledFunctions[timeoutKey] = undefined;
2147   };
2148 
2149 };
2150 
2151 jasmine.FakeTimer.prototype.reset = function() {
2152   this.timeoutsMade = 0;
2153   this.scheduledFunctions = {};
2154   this.nowMillis = 0;
2155 };
2156 
2157 jasmine.FakeTimer.prototype.tick = function(millis) {
2158   var oldMillis = this.nowMillis;
2159   var newMillis = oldMillis + millis;
2160   this.runFunctionsWithinRange(oldMillis, newMillis);
2161   this.nowMillis = newMillis;
2162 };
2163 
2164 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
2165   var scheduledFunc;
2166   var funcsToRun = [];
2167   for (var timeoutKey in this.scheduledFunctions) {
2168     scheduledFunc = this.scheduledFunctions[timeoutKey];
2169     if (scheduledFunc != undefined &&
2170         scheduledFunc.runAtMillis >= oldMillis &&
2171         scheduledFunc.runAtMillis <= nowMillis) {
2172       funcsToRun.push(scheduledFunc);
2173       this.scheduledFunctions[timeoutKey] = undefined;
2174     }
2175   }
2176 
2177   if (funcsToRun.length > 0) {
2178     funcsToRun.sort(function(a, b) {
2179       return a.runAtMillis - b.runAtMillis;
2180     });
2181     for (var i = 0; i < funcsToRun.length; ++i) {
2182       try {
2183         var funcToRun = funcsToRun[i];
2184         this.nowMillis = funcToRun.runAtMillis;
2185         funcToRun.funcToCall();
2186         if (funcToRun.recurring) {
2187           this.scheduleFunction(funcToRun.timeoutKey,
2188             funcToRun.funcToCall,
2189             funcToRun.millis,
2190             true);
2191         }
2192       } catch(e) {
2193       }
2194     }
2195     this.runFunctionsWithinRange(oldMillis, nowMillis);
2196   }
2197 };
2198 
2199 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
2200   this.scheduledFunctions[timeoutKey] = {
2201     runAtMillis: this.nowMillis + millis,
2202     funcToCall: funcToCall,
2203     recurring: recurring,
2204     timeoutKey: timeoutKey,
2205     millis: millis
2206   };
2207 };
2208 
2209 
2210 jasmine.Clock = {
2211   defaultFakeTimer: new jasmine.FakeTimer(),
2212 
2213   reset: function() {
2214     jasmine.Clock.assertInstalled();
2215     jasmine.Clock.defaultFakeTimer.reset();
2216   },
2217 
2218   tick: function(millis) {
2219     jasmine.Clock.assertInstalled();
2220     jasmine.Clock.defaultFakeTimer.tick(millis);
2221   },
2222 
2223   runFunctionsWithinRange: function(oldMillis, nowMillis) {
2224     jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
2225   },
2226 
2227   scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
2228     jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
2229   },
2230 
2231   useMock: function() {
2232     var spec = jasmine.getEnv().currentSpec;
2233     spec.after(jasmine.Clock.uninstallMock);
2234 
2235     jasmine.Clock.installMock();
2236   },
2237 
2238   installMock: function() {
2239     jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
2240   },
2241 
2242   uninstallMock: function() {
2243     jasmine.Clock.assertInstalled();
2244     jasmine.Clock.installed = jasmine.Clock.real;
2245   },
2246 
2247   real: {
2248     setTimeout: window.setTimeout,
2249     clearTimeout: window.clearTimeout,
2250     setInterval: window.setInterval,
2251     clearInterval: window.clearInterval
2252   },
2253 
2254   assertInstalled: function() {
2255     if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) {
2256       throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
2257     }
2258   },
2259 
2260   installed: null
2261 };
2262 jasmine.Clock.installed = jasmine.Clock.real;
2263 
2264 //else for IE support
2265 window.setTimeout = function(funcToCall, millis) {
2266   if (jasmine.Clock.installed.setTimeout.apply) {
2267     return jasmine.Clock.installed.setTimeout.apply(this, arguments);
2268   } else {
2269     return jasmine.Clock.installed.setTimeout(funcToCall, millis);
2270   }
2271 };
2272 
2273 window.setInterval = function(funcToCall, millis) {
2274   if (jasmine.Clock.installed.setInterval.apply) {
2275     return jasmine.Clock.installed.setInterval.apply(this, arguments);
2276   } else {
2277     return jasmine.Clock.installed.setInterval(funcToCall, millis);
2278   }
2279 };
2280 
2281 window.clearTimeout = function(timeoutKey) {
2282   if (jasmine.Clock.installed.clearTimeout.apply) {
2283     return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
2284   } else {
2285     return jasmine.Clock.installed.clearTimeout(timeoutKey);
2286   }
2287 };
2288 
2289 window.clearInterval = function(timeoutKey) {
2290   if (jasmine.Clock.installed.clearTimeout.apply) {
2291     return jasmine.Clock.installed.clearInterval.apply(this, arguments);
2292   } else {
2293   return jasmine.Clock.installed.clearInterval(timeoutKey);
2294   }
2295 };
2296 
2297