From 4620ea6a44714dd78e6c612fca30054c0959de80 Mon Sep 17 00:00:00 2001 From: ragaskar Date: Fri, 4 Sep 2009 10:57:08 -0700 Subject: [PATCH] Merged in Xian's speed fixes --- Rakefile | 7 +- doc/files.html | 2 +- doc/index.html | 2 +- doc/symbols/_global_.html | 2 +- doc/symbols/jasmine.Block.html | 2 +- doc/symbols/jasmine.Env.html | 2 +- doc/symbols/jasmine.JsApiReporter.html | 2 +- doc/symbols/jasmine.MultiReporter.html | 2 +- doc/symbols/jasmine.NestedResults.html | 2 +- doc/symbols/jasmine.Reporter.html | 2 +- doc/symbols/jasmine.Runner.html | 59 +- doc/symbols/jasmine.Spec.html | 2 +- doc/symbols/jasmine.Spy.html | 2 +- doc/symbols/jasmine.Suite.html | 59 +- doc/symbols/jasmine.html | 2 +- doc/symbols/jasmine.util.html | 2 +- doc/symbols/src/lib_jasmine-0.9.0.js.html | 936 +++++++++++----------- lib/jasmine-0.9.0.js | 16 +- spec/suites/ReporterSpec.js | 7 - spec/suites/RunnerSpec.js | 5 +- spec/suites/SpecRunningSpec.js | 17 - src/Env.js | 2 + src/Queue.js | 12 +- 23 files changed, 630 insertions(+), 516 deletions(-) diff --git a/Rakefile b/Rakefile index 712b5b4..7dae5fb 100644 --- a/Rakefile +++ b/Rakefile @@ -68,8 +68,9 @@ desc "Run jasmine tests via server" task :jasmine_server do require File.expand_path(File.join(File.dirname(__FILE__), "contrib/ruby/jasmine_spec_builder")) - includes = jasmine_sources + ['lib/TrivialReporter.js'] - spec_files = Dir.glob("spec/**/*.js") + includes = lambda do + jasmine_sources + ['lib/TrivialReporter.js'] + Dir.glob("spec/**/*.js") + end dir_mappings = { "/spec" => "spec", @@ -80,5 +81,5 @@ task :jasmine_server do puts "your tests are here:" puts " http://localhost:8888/run.html" - Jasmine::SimpleServer.start(8888, includes + spec_files, dir_mappings) + Jasmine::SimpleServer.start(8888, includes, dir_mappings) end \ No newline at end of file diff --git a/doc/files.html b/doc/files.html index 4ce1733..a6c8551 100644 --- a/doc/files.html +++ b/doc/files.html @@ -258,7 +258,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 9aa814f..ce8e9db 100644 --- a/doc/index.html +++ b/doc/index.html @@ -300,7 +300,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index 663deb5..5845403 100644 --- a/doc/symbols/_global_.html +++ b/doc/symbols/_global_.html @@ -908,7 +908,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Block.html b/doc/symbols/jasmine.Block.html index 0577d1f..6835fbd 100644 --- a/doc/symbols/jasmine.Block.html +++ b/doc/symbols/jasmine.Block.html @@ -339,7 +339,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Env.html b/doc/symbols/jasmine.Env.html index b62d29c..2a8f660 100644 --- a/doc/symbols/jasmine.Env.html +++ b/doc/symbols/jasmine.Env.html @@ -384,7 +384,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.JsApiReporter.html b/doc/symbols/jasmine.JsApiReporter.html index ff550f8..8e70791 100644 --- a/doc/symbols/jasmine.JsApiReporter.html +++ b/doc/symbols/jasmine.JsApiReporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.MultiReporter.html b/doc/symbols/jasmine.MultiReporter.html index c8ed700..c60536d 100644 --- a/doc/symbols/jasmine.MultiReporter.html +++ b/doc/symbols/jasmine.MultiReporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index 96a0b90..5e59f6f 100644 --- a/doc/symbols/jasmine.NestedResults.html +++ b/doc/symbols/jasmine.NestedResults.html @@ -700,7 +700,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Reporter.html b/doc/symbols/jasmine.Reporter.html index b18f169..d2e7b63 100644 --- a/doc/symbols/jasmine.Reporter.html +++ b/doc/symbols/jasmine.Reporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index 44c7109..fd14f4c 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -267,6 +267,33 @@ ul.inheritsList + + + + + + + + + + + + + + + + + + +
Method Summary
Method AttributesMethod Name and Description
  + +
+
+ + + + @@ -316,6 +343,36 @@ ul.inheritsList +
+ Method Detail +
+ + +
+ + + getAllSuites() + +
+
+ + + +
+ + + + + + + + + + + + + + @@ -327,7 +384,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spec.html b/doc/symbols/jasmine.Spec.html index a5d5ade..d46090d 100644 --- a/doc/symbols/jasmine.Spec.html +++ b/doc/symbols/jasmine.Spec.html @@ -339,7 +339,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index 94f3039..3885e03 100644 --- a/doc/symbols/jasmine.Spy.html +++ b/doc/symbols/jasmine.Spy.html @@ -845,7 +845,7 @@ expect(foo.bar.callCount).toEqual(0);
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index ada2fd6..69cf170 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -267,6 +267,33 @@ ul.inheritsList + + + + + + + + + + + + + + + + + + +
Method Summary
Method AttributesMethod Name and Description
  + +
+
+ + + + @@ -334,6 +361,36 @@ ul.inheritsList +
+ Method Detail +
+ + +
+ + + specCount() + +
+
+ + + +
+ + + + + + + + + + + + + + @@ -345,7 +402,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index 2f38cee..4fd0f11 100644 --- a/doc/symbols/jasmine.html +++ b/doc/symbols/jasmine.html @@ -678,7 +678,7 @@ Jasmine environment.
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index 508d2ef..3d3e25d 100644 --- a/doc/symbols/jasmine.util.html +++ b/doc/symbols/jasmine.util.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Wed Sep 02 2009 07:41:14 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT)
diff --git a/doc/symbols/src/lib_jasmine-0.9.0.js.html b/doc/symbols/src/lib_jasmine-0.9.0.js.html index e76c5a4..2060fa6 100644 --- a/doc/symbols/src/lib_jasmine-0.9.0.js.html +++ b/doc/symbols/src/lib_jasmine-0.9.0.js.html @@ -524,7 +524,7 @@ 517 "major": 0, 518 "minor": 9, 519 "build": 0, -520 "revision": 1251901478 +520 "revision": 1251902474 521 }; 522 /** 523 * @namespace @@ -846,7 +846,7 @@ 839 840 jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { 841 this.started = true; -842 var suites = runner.getAllSuites(); +842 var suites = runner.suites(); 843 for (var i = 0; i < suites.length; i++) { 844 var suite = suites[i]; 845 this.suites.push(this.summarize_(suite)); @@ -1515,7 +1515,7 @@ 1508 var self = this; 1509 self.env = env; 1510 self.queue = new jasmine.Queue(env); -1511 self.suites = []; +1511 self.suites_ = []; 1512 }; 1513 1514 jasmine.Runner.prototype.execute = function() { @@ -1533,7 +1533,7 @@ 1526 }; 1527 1528 jasmine.Runner.prototype.addSuite = function(suite) { -1529 this.suites.push(suite); +1529 this.suites_.push(suite); 1530 }; 1531 1532 jasmine.Runner.prototype.add = function(block) { @@ -1543,484 +1543,490 @@ 1536 this.queue.add(block); 1537 }; 1538 -1539 +1539 /** @deprecated */ 1540 jasmine.Runner.prototype.getAllSuites = function() { -1541 return this.suites; +1541 return this.suites_; 1542 }; 1543 -1544 jasmine.Runner.prototype.getResults = function() { -1545 return this.queue.getResults(); -1546 }; -1547 /** -1548 * Internal representation of a Jasmine specification, or test. -1549 * -1550 * @constructor -1551 * @param {jasmine.Env} env -1552 * @param {jasmine.Suite} suite -1553 * @param {String} description -1554 */ -1555 jasmine.Spec = function(env, suite, description) { -1556 var spec = this; -1557 spec.id = env.nextSpecId_++; -1558 spec.env = env; -1559 spec.suite = suite; -1560 spec.description = description; -1561 spec.queue = new jasmine.Queue(env); -1562 -1563 spec.afterCallbacks = []; -1564 spec.spies_ = []; -1565 -1566 spec.results = new jasmine.NestedResults(); -1567 spec.results.description = description; -1568 spec.matchersClass = null; -1569 }; +1544 +1545 jasmine.Runner.prototype.suites = function() { +1546 return this.suites_; +1547 }; +1548 +1549 jasmine.Runner.prototype.getResults = function() { +1550 return this.queue.getResults(); +1551 }; +1552 /** +1553 * Internal representation of a Jasmine specification, or test. +1554 * +1555 * @constructor +1556 * @param {jasmine.Env} env +1557 * @param {jasmine.Suite} suite +1558 * @param {String} description +1559 */ +1560 jasmine.Spec = function(env, suite, description) { +1561 var spec = this; +1562 spec.id = env.nextSpecId_++; +1563 spec.env = env; +1564 spec.suite = suite; +1565 spec.description = description; +1566 spec.queue = new jasmine.Queue(env); +1567 +1568 spec.afterCallbacks = []; +1569 spec.spies_ = []; 1570 -1571 jasmine.Spec.prototype.getFullName = function() { -1572 return this.suite.getFullName() + ' ' + this.description + '.'; -1573 }; -1574 -1575 jasmine.Spec.prototype.getResults = function() { -1576 return this.results; -1577 }; -1578 -1579 jasmine.Spec.prototype.runs = function (func) { -1580 var block = new jasmine.Block(this.env, func, this); -1581 this.addToQueue(block); -1582 return this; -1583 }; -1584 -1585 jasmine.Spec.prototype.addToQueue = function (block) { -1586 if (this.queue.isRunning()) { -1587 this.queue.insertNext(block); -1588 } else { -1589 this.queue.add(block); -1590 } -1591 }; -1592 -1593 /** -1594 * @private -1595 * @deprecated -1596 */ -1597 jasmine.Spec.prototype.expects_that = function(actual) { -1598 return this.expect(actual); -1599 }; -1600 -1601 /** -1602 * @private -1603 */ -1604 jasmine.Spec.prototype.expect = function(actual) { -1605 return new (this.getMatchersClass_())(this.env, actual, this.results); -1606 }; -1607 -1608 jasmine.Spec.prototype.waits = function(timeout) { -1609 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); -1610 this.addToQueue(waitsFunc); -1611 return this; -1612 }; -1613 -1614 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { -1615 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); -1616 this.addToQueue(waitsForFunc); -1617 return this; -1618 }; -1619 -1620 jasmine.Spec.prototype.failWithException = function (e) { -1621 this.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null)); -1622 }; -1623 -1624 jasmine.Spec.prototype.getMatchersClass_ = function() { -1625 return this.matchersClass || jasmine.Matchers; -1626 }; -1627 -1628 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { -1629 var parent = this.getMatchersClass_(); -1630 var newMatchersClass = function() { -1631 parent.apply(this, arguments); -1632 }; -1633 jasmine.util.inherit(newMatchersClass, parent); -1634 for (var method in matchersPrototype) { -1635 newMatchersClass.prototype[method] = matchersPrototype[method]; -1636 } -1637 this.matchersClass = newMatchersClass; -1638 }; -1639 -1640 jasmine.Spec.prototype.finishCallback = function() { -1641 this.env.reporter.reportSpecResults(this); -1642 }; -1643 -1644 jasmine.Spec.prototype.finish = function(onComplete) { -1645 this.removeAllSpies(); -1646 this.finishCallback(); -1647 if (onComplete) { -1648 onComplete(); -1649 } -1650 }; -1651 -1652 jasmine.Spec.prototype.after = function(doAfter, test) { -1653 -1654 if (this.queue.isRunning()) { -1655 this.queue.add(new jasmine.Block(this.env, doAfter, this)); -1656 } else { -1657 this.afterCallbacks.unshift(doAfter); -1658 } -1659 }; -1660 -1661 jasmine.Spec.prototype.execute = function(onComplete) { -1662 var spec = this; -1663 if (!spec.env.specFilter(spec)) { -1664 spec.results.skipped = true; -1665 spec.finish(onComplete); -1666 return; -1667 } -1668 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); -1669 -1670 spec.env.currentSpec = spec; -1671 spec.env.currentlyRunningTests = true; -1672 -1673 spec.addBeforesAndAftersToQueue(); +1571 spec.results = new jasmine.NestedResults(); +1572 spec.results.description = description; +1573 spec.matchersClass = null; +1574 }; +1575 +1576 jasmine.Spec.prototype.getFullName = function() { +1577 return this.suite.getFullName() + ' ' + this.description + '.'; +1578 }; +1579 +1580 jasmine.Spec.prototype.getResults = function() { +1581 return this.results; +1582 }; +1583 +1584 jasmine.Spec.prototype.runs = function (func) { +1585 var block = new jasmine.Block(this.env, func, this); +1586 this.addToQueue(block); +1587 return this; +1588 }; +1589 +1590 jasmine.Spec.prototype.addToQueue = function (block) { +1591 if (this.queue.isRunning()) { +1592 this.queue.insertNext(block); +1593 } else { +1594 this.queue.add(block); +1595 } +1596 }; +1597 +1598 /** +1599 * @private +1600 * @deprecated +1601 */ +1602 jasmine.Spec.prototype.expects_that = function(actual) { +1603 return this.expect(actual); +1604 }; +1605 +1606 /** +1607 * @private +1608 */ +1609 jasmine.Spec.prototype.expect = function(actual) { +1610 return new (this.getMatchersClass_())(this.env, actual, this.results); +1611 }; +1612 +1613 jasmine.Spec.prototype.waits = function(timeout) { +1614 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); +1615 this.addToQueue(waitsFunc); +1616 return this; +1617 }; +1618 +1619 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { +1620 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); +1621 this.addToQueue(waitsForFunc); +1622 return this; +1623 }; +1624 +1625 jasmine.Spec.prototype.failWithException = function (e) { +1626 this.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null)); +1627 }; +1628 +1629 jasmine.Spec.prototype.getMatchersClass_ = function() { +1630 return this.matchersClass || jasmine.Matchers; +1631 }; +1632 +1633 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { +1634 var parent = this.getMatchersClass_(); +1635 var newMatchersClass = function() { +1636 parent.apply(this, arguments); +1637 }; +1638 jasmine.util.inherit(newMatchersClass, parent); +1639 for (var method in matchersPrototype) { +1640 newMatchersClass.prototype[method] = matchersPrototype[method]; +1641 } +1642 this.matchersClass = newMatchersClass; +1643 }; +1644 +1645 jasmine.Spec.prototype.finishCallback = function() { +1646 this.env.reporter.reportSpecResults(this); +1647 }; +1648 +1649 jasmine.Spec.prototype.finish = function(onComplete) { +1650 this.removeAllSpies(); +1651 this.finishCallback(); +1652 if (onComplete) { +1653 onComplete(); +1654 } +1655 }; +1656 +1657 jasmine.Spec.prototype.after = function(doAfter, test) { +1658 +1659 if (this.queue.isRunning()) { +1660 this.queue.add(new jasmine.Block(this.env, doAfter, this)); +1661 } else { +1662 this.afterCallbacks.unshift(doAfter); +1663 } +1664 }; +1665 +1666 jasmine.Spec.prototype.execute = function(onComplete) { +1667 var spec = this; +1668 if (!spec.env.specFilter(spec)) { +1669 spec.results.skipped = true; +1670 spec.finish(onComplete); +1671 return; +1672 } +1673 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); 1674 -1675 spec.queue.start(function () { -1676 spec.finish(onComplete); -1677 }); -1678 spec.env.currentlyRunningTests = false; -1679 }; -1680 -1681 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { -1682 for (var suite = this.suite; suite; suite = suite.parentSuite) { -1683 if (suite.beforeQueue) { -1684 for (var i = 0; i < suite.beforeQueue.length; i++) -1685 this.queue.addBefore(new jasmine.Block(this.env, suite.beforeQueue[i], this)); -1686 } -1687 } -1688 for (i = 0; i < this.afterCallbacks.length; i++) { -1689 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); -1690 } -1691 for (suite = this.suite; suite; suite = suite.parentSuite) { -1692 if (suite.afterQueue) { -1693 for (var j = 0; j < suite.afterQueue.length; j++) -1694 this.queue.add(new jasmine.Block(this.env, suite.afterQueue[j], this)); -1695 } -1696 } -1697 }; -1698 -1699 jasmine.Spec.prototype.explodes = function() { -1700 throw 'explodes function should not have been called'; -1701 }; -1702 -1703 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { -1704 if (obj == undefined) { -1705 throw "spyOn could not find an object to spy upon for " + methodName + "()"; -1706 } +1675 spec.env.currentSpec = spec; +1676 spec.env.currentlyRunningTests = true; +1677 +1678 spec.addBeforesAndAftersToQueue(); +1679 +1680 spec.queue.start(function () { +1681 spec.finish(onComplete); +1682 }); +1683 spec.env.currentlyRunningTests = false; +1684 }; +1685 +1686 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { +1687 for (var suite = this.suite; suite; suite = suite.parentSuite) { +1688 if (suite.beforeQueue) { +1689 for (var i = 0; i < suite.beforeQueue.length; i++) +1690 this.queue.addBefore(new jasmine.Block(this.env, suite.beforeQueue[i], this)); +1691 } +1692 } +1693 for (i = 0; i < this.afterCallbacks.length; i++) { +1694 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); +1695 } +1696 for (suite = this.suite; suite; suite = suite.parentSuite) { +1697 if (suite.afterQueue) { +1698 for (var j = 0; j < suite.afterQueue.length; j++) +1699 this.queue.add(new jasmine.Block(this.env, suite.afterQueue[j], this)); +1700 } +1701 } +1702 }; +1703 +1704 jasmine.Spec.prototype.explodes = function() { +1705 throw 'explodes function should not have been called'; +1706 }; 1707 -1708 if (!ignoreMethodDoesntExist && obj[methodName] === undefined) { -1709 throw methodName + '() method does not exist'; -1710 } -1711 -1712 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { -1713 throw new Error(methodName + ' has already been spied upon'); -1714 } -1715 -1716 var spyObj = jasmine.createSpy(methodName); -1717 -1718 this.spies_.push(spyObj); -1719 spyObj.baseObj = obj; -1720 spyObj.methodName = methodName; -1721 spyObj.originalValue = obj[methodName]; +1708 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { +1709 if (obj == undefined) { +1710 throw "spyOn could not find an object to spy upon for " + methodName + "()"; +1711 } +1712 +1713 if (!ignoreMethodDoesntExist && obj[methodName] === undefined) { +1714 throw methodName + '() method does not exist'; +1715 } +1716 +1717 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { +1718 throw new Error(methodName + ' has already been spied upon'); +1719 } +1720 +1721 var spyObj = jasmine.createSpy(methodName); 1722 -1723 obj[methodName] = spyObj; -1724 -1725 return spyObj; -1726 }; +1723 this.spies_.push(spyObj); +1724 spyObj.baseObj = obj; +1725 spyObj.methodName = methodName; +1726 spyObj.originalValue = obj[methodName]; 1727 -1728 jasmine.Spec.prototype.removeAllSpies = function() { -1729 for (var i = 0; i < this.spies_.length; i++) { -1730 var spy = this.spies_[i]; -1731 spy.baseObj[spy.methodName] = spy.originalValue; -1732 } -1733 this.spies_ = []; -1734 }; -1735 -1736 /** -1737 * Internal representation of a Jasmine suite. -1738 * -1739 * @constructor -1740 * @param {jasmine.Env} env -1741 * @param {String} description -1742 * @param {Function} specDefinitions -1743 * @param {jasmine.Suite} parentSuite -1744 */ -1745 jasmine.Suite = function(env, description, specDefinitions, parentSuite) { -1746 var self = this; -1747 self.id = env.nextSuiteId_++; -1748 self.description = description; -1749 self.queue = new jasmine.Queue(env); -1750 self.parentSuite = parentSuite; -1751 self.env = env; -1752 self.beforeQueue = []; -1753 self.afterQueue = []; -1754 self.specs_ = []; -1755 }; -1756 -1757 jasmine.Suite.prototype.getFullName = function() { -1758 var fullName = this.description; -1759 for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { -1760 fullName = parentSuite.description + ' ' + fullName; -1761 } -1762 return fullName; -1763 }; -1764 -1765 jasmine.Suite.prototype.finish = function(onComplete) { -1766 this.env.reporter.reportSuiteResults(this); -1767 this.finished = true; -1768 if (typeof(onComplete) == 'function') { -1769 onComplete(); -1770 } -1771 }; -1772 -1773 jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { -1774 beforeEachFunction.typeName = 'beforeEach'; -1775 this.beforeQueue.push(beforeEachFunction); +1728 obj[methodName] = spyObj; +1729 +1730 return spyObj; +1731 }; +1732 +1733 jasmine.Spec.prototype.removeAllSpies = function() { +1734 for (var i = 0; i < this.spies_.length; i++) { +1735 var spy = this.spies_[i]; +1736 spy.baseObj[spy.methodName] = spy.originalValue; +1737 } +1738 this.spies_ = []; +1739 }; +1740 +1741 /** +1742 * Internal representation of a Jasmine suite. +1743 * +1744 * @constructor +1745 * @param {jasmine.Env} env +1746 * @param {String} description +1747 * @param {Function} specDefinitions +1748 * @param {jasmine.Suite} parentSuite +1749 */ +1750 jasmine.Suite = function(env, description, specDefinitions, parentSuite) { +1751 var self = this; +1752 self.id = env.nextSuiteId_++; +1753 self.description = description; +1754 self.queue = new jasmine.Queue(env); +1755 self.parentSuite = parentSuite; +1756 self.env = env; +1757 self.beforeQueue = []; +1758 self.afterQueue = []; +1759 self.specs_ = []; +1760 }; +1761 +1762 jasmine.Suite.prototype.getFullName = function() { +1763 var fullName = this.description; +1764 for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { +1765 fullName = parentSuite.description + ' ' + fullName; +1766 } +1767 return fullName; +1768 }; +1769 +1770 jasmine.Suite.prototype.finish = function(onComplete) { +1771 this.env.reporter.reportSuiteResults(this); +1772 this.finished = true; +1773 if (typeof(onComplete) == 'function') { +1774 onComplete(); +1775 } 1776 }; 1777 -1778 jasmine.Suite.prototype.afterEach = function(afterEachFunction) { -1779 afterEachFunction.typeName = 'afterEach'; -1780 this.afterQueue.push(afterEachFunction); +1778 jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { +1779 beforeEachFunction.typeName = 'beforeEach'; +1780 this.beforeQueue.push(beforeEachFunction); 1781 }; 1782 -1783 jasmine.Suite.prototype.getResults = function() { -1784 return this.queue.getResults(); -1785 }; -1786 -1787 jasmine.Suite.prototype.add = function(block) { -1788 if (block instanceof jasmine.Suite) { -1789 this.env.currentRunner.addSuite(block); -1790 } else { -1791 this.specs_.push(block); -1792 } -1793 this.queue.add(block); -1794 }; -1795 -1796 jasmine.Suite.prototype.specCount = function() { -1797 return this.specs_.length; -1798 }; -1799 -1800 jasmine.Suite.prototype.specs = function() { -1801 return this.specs_; -1802 }; -1803 -1804 jasmine.Suite.prototype.execute = function(onComplete) { -1805 var self = this; -1806 this.queue.start(function () { -1807 self.finish(onComplete); -1808 }); -1809 }; -1810 jasmine.WaitsBlock = function(env, timeout, spec) { -1811 this.timeout = timeout; -1812 jasmine.Block.call(this, env, null, spec); -1813 }; -1814 -1815 jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); -1816 -1817 jasmine.WaitsBlock.prototype.execute = function (onComplete) { -1818 this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); -1819 this.env.setTimeout(function () { -1820 onComplete(); -1821 }, this.timeout); -1822 }; -1823 jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { -1824 this.timeout = timeout; -1825 this.latchFunction = latchFunction; -1826 this.message = message; -1827 this.totalTimeSpentWaitingForLatch = 0; -1828 jasmine.Block.call(this, env, null, spec); -1829 }; -1830 -1831 jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); -1832 -1833 jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100; -1834 -1835 jasmine.WaitsForBlock.prototype.execute = function (onComplete) { -1836 var self = this; -1837 self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen')); -1838 var latchFunctionResult; -1839 try { -1840 latchFunctionResult = self.latchFunction.apply(self.spec); -1841 } catch (e) { -1842 self.fail(e); -1843 onComplete(); -1844 return; -1845 } -1846 -1847 if (latchFunctionResult) { -1848 onComplete(); -1849 } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) { -1850 var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen'); -1851 self.fail({ -1852 name: 'timeout', -1853 message: message -1854 }); -1855 self.spec._next(); -1856 } else { -1857 self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; -1858 self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); -1859 } -1860 }; -1861 // Mock setTimeout, clearTimeout -1862 // Contributed by Pivotal Computer Systems, www.pivotalsf.com -1863 -1864 jasmine.FakeTimer = function() { -1865 this.reset(); -1866 -1867 var self = this; -1868 self.setTimeout = function(funcToCall, millis) { -1869 self.timeoutsMade++; -1870 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); -1871 return self.timeoutsMade; -1872 }; -1873 -1874 self.setInterval = function(funcToCall, millis) { +1783 jasmine.Suite.prototype.afterEach = function(afterEachFunction) { +1784 afterEachFunction.typeName = 'afterEach'; +1785 this.afterQueue.push(afterEachFunction); +1786 }; +1787 +1788 jasmine.Suite.prototype.getResults = function() { +1789 return this.queue.getResults(); +1790 }; +1791 +1792 jasmine.Suite.prototype.add = function(block) { +1793 if (block instanceof jasmine.Suite) { +1794 this.env.currentRunner.addSuite(block); +1795 } else { +1796 this.specs_.push(block); +1797 } +1798 this.queue.add(block); +1799 }; +1800 +1801 /** @deprecated */ +1802 jasmine.Suite.prototype.specCount = function() { +1803 return this.specs_.length; +1804 }; +1805 +1806 jasmine.Suite.prototype.specs = function() { +1807 return this.specs_; +1808 }; +1809 +1810 jasmine.Suite.prototype.execute = function(onComplete) { +1811 var self = this; +1812 this.queue.start(function () { +1813 self.finish(onComplete); +1814 }); +1815 }; +1816 jasmine.WaitsBlock = function(env, timeout, spec) { +1817 this.timeout = timeout; +1818 jasmine.Block.call(this, env, null, spec); +1819 }; +1820 +1821 jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); +1822 +1823 jasmine.WaitsBlock.prototype.execute = function (onComplete) { +1824 this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); +1825 this.env.setTimeout(function () { +1826 onComplete(); +1827 }, this.timeout); +1828 }; +1829 jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { +1830 this.timeout = timeout; +1831 this.latchFunction = latchFunction; +1832 this.message = message; +1833 this.totalTimeSpentWaitingForLatch = 0; +1834 jasmine.Block.call(this, env, null, spec); +1835 }; +1836 +1837 jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); +1838 +1839 jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100; +1840 +1841 jasmine.WaitsForBlock.prototype.execute = function (onComplete) { +1842 var self = this; +1843 self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen')); +1844 var latchFunctionResult; +1845 try { +1846 latchFunctionResult = self.latchFunction.apply(self.spec); +1847 } catch (e) { +1848 self.fail(e); +1849 onComplete(); +1850 return; +1851 } +1852 +1853 if (latchFunctionResult) { +1854 onComplete(); +1855 } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) { +1856 var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen'); +1857 self.fail({ +1858 name: 'timeout', +1859 message: message +1860 }); +1861 self.spec._next(); +1862 } else { +1863 self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; +1864 self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); +1865 } +1866 }; +1867 // Mock setTimeout, clearTimeout +1868 // Contributed by Pivotal Computer Systems, www.pivotalsf.com +1869 +1870 jasmine.FakeTimer = function() { +1871 this.reset(); +1872 +1873 var self = this; +1874 self.setTimeout = function(funcToCall, millis) { 1875 self.timeoutsMade++; -1876 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); +1876 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); 1877 return self.timeoutsMade; 1878 }; 1879 -1880 self.clearTimeout = function(timeoutKey) { -1881 self.scheduledFunctions[timeoutKey] = undefined; -1882 }; -1883 -1884 self.clearInterval = function(timeoutKey) { -1885 self.scheduledFunctions[timeoutKey] = undefined; -1886 }; -1887 -1888 }; +1880 self.setInterval = function(funcToCall, millis) { +1881 self.timeoutsMade++; +1882 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); +1883 return self.timeoutsMade; +1884 }; +1885 +1886 self.clearTimeout = function(timeoutKey) { +1887 self.scheduledFunctions[timeoutKey] = undefined; +1888 }; 1889 -1890 jasmine.FakeTimer.prototype.reset = function() { -1891 this.timeoutsMade = 0; -1892 this.scheduledFunctions = {}; -1893 this.nowMillis = 0; +1890 self.clearInterval = function(timeoutKey) { +1891 self.scheduledFunctions[timeoutKey] = undefined; +1892 }; +1893 1894 }; 1895 -1896 jasmine.FakeTimer.prototype.tick = function(millis) { -1897 var oldMillis = this.nowMillis; -1898 var newMillis = oldMillis + millis; -1899 this.runFunctionsWithinRange(oldMillis, newMillis); -1900 this.nowMillis = newMillis; -1901 }; -1902 -1903 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { -1904 var scheduledFunc; -1905 var funcsToRun = []; -1906 for (var timeoutKey in this.scheduledFunctions) { -1907 scheduledFunc = this.scheduledFunctions[timeoutKey]; -1908 if (scheduledFunc != undefined && -1909 scheduledFunc.runAtMillis >= oldMillis && -1910 scheduledFunc.runAtMillis <= nowMillis) { -1911 funcsToRun.push(scheduledFunc); -1912 this.scheduledFunctions[timeoutKey] = undefined; -1913 } -1914 } -1915 -1916 if (funcsToRun.length > 0) { -1917 funcsToRun.sort(function(a, b) { -1918 return a.runAtMillis - b.runAtMillis; -1919 }); -1920 for (var i = 0; i < funcsToRun.length; ++i) { -1921 try { -1922 var funcToRun = funcsToRun[i]; -1923 this.nowMillis = funcToRun.runAtMillis; -1924 funcToRun.funcToCall(); -1925 if (funcToRun.recurring) { -1926 this.scheduleFunction(funcToRun.timeoutKey, -1927 funcToRun.funcToCall, -1928 funcToRun.millis, -1929 true); -1930 } -1931 } catch(e) { -1932 } -1933 } -1934 this.runFunctionsWithinRange(oldMillis, nowMillis); -1935 } -1936 }; -1937 -1938 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { -1939 this.scheduledFunctions[timeoutKey] = { -1940 runAtMillis: this.nowMillis + millis, -1941 funcToCall: funcToCall, -1942 recurring: recurring, -1943 timeoutKey: timeoutKey, -1944 millis: millis -1945 }; -1946 }; -1947 -1948 -1949 jasmine.Clock = { -1950 defaultFakeTimer: new jasmine.FakeTimer(), -1951 -1952 reset: function() { -1953 jasmine.Clock.assertInstalled(); -1954 jasmine.Clock.defaultFakeTimer.reset(); -1955 }, -1956 -1957 tick: function(millis) { -1958 jasmine.Clock.assertInstalled(); -1959 jasmine.Clock.defaultFakeTimer.tick(millis); -1960 }, -1961 -1962 runFunctionsWithinRange: function(oldMillis, nowMillis) { -1963 jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); -1964 }, -1965 -1966 scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { -1967 jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); -1968 }, -1969 -1970 useMock: function() { -1971 var spec = jasmine.getEnv().currentSpec; -1972 spec.after(jasmine.Clock.uninstallMock); -1973 -1974 jasmine.Clock.installMock(); -1975 }, -1976 -1977 installMock: function() { -1978 jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; -1979 }, -1980 -1981 uninstallMock: function() { -1982 jasmine.Clock.assertInstalled(); -1983 jasmine.Clock.installed = jasmine.Clock.real; -1984 }, -1985 -1986 real: { -1987 setTimeout: window.setTimeout, -1988 clearTimeout: window.clearTimeout, -1989 setInterval: window.setInterval, -1990 clearInterval: window.clearInterval -1991 }, -1992 -1993 assertInstalled: function() { -1994 if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) { -1995 throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); -1996 } -1997 }, +1896 jasmine.FakeTimer.prototype.reset = function() { +1897 this.timeoutsMade = 0; +1898 this.scheduledFunctions = {}; +1899 this.nowMillis = 0; +1900 }; +1901 +1902 jasmine.FakeTimer.prototype.tick = function(millis) { +1903 var oldMillis = this.nowMillis; +1904 var newMillis = oldMillis + millis; +1905 this.runFunctionsWithinRange(oldMillis, newMillis); +1906 this.nowMillis = newMillis; +1907 }; +1908 +1909 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { +1910 var scheduledFunc; +1911 var funcsToRun = []; +1912 for (var timeoutKey in this.scheduledFunctions) { +1913 scheduledFunc = this.scheduledFunctions[timeoutKey]; +1914 if (scheduledFunc != undefined && +1915 scheduledFunc.runAtMillis >= oldMillis && +1916 scheduledFunc.runAtMillis <= nowMillis) { +1917 funcsToRun.push(scheduledFunc); +1918 this.scheduledFunctions[timeoutKey] = undefined; +1919 } +1920 } +1921 +1922 if (funcsToRun.length > 0) { +1923 funcsToRun.sort(function(a, b) { +1924 return a.runAtMillis - b.runAtMillis; +1925 }); +1926 for (var i = 0; i < funcsToRun.length; ++i) { +1927 try { +1928 var funcToRun = funcsToRun[i]; +1929 this.nowMillis = funcToRun.runAtMillis; +1930 funcToRun.funcToCall(); +1931 if (funcToRun.recurring) { +1932 this.scheduleFunction(funcToRun.timeoutKey, +1933 funcToRun.funcToCall, +1934 funcToRun.millis, +1935 true); +1936 } +1937 } catch(e) { +1938 } +1939 } +1940 this.runFunctionsWithinRange(oldMillis, nowMillis); +1941 } +1942 }; +1943 +1944 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { +1945 this.scheduledFunctions[timeoutKey] = { +1946 runAtMillis: this.nowMillis + millis, +1947 funcToCall: funcToCall, +1948 recurring: recurring, +1949 timeoutKey: timeoutKey, +1950 millis: millis +1951 }; +1952 }; +1953 +1954 +1955 jasmine.Clock = { +1956 defaultFakeTimer: new jasmine.FakeTimer(), +1957 +1958 reset: function() { +1959 jasmine.Clock.assertInstalled(); +1960 jasmine.Clock.defaultFakeTimer.reset(); +1961 }, +1962 +1963 tick: function(millis) { +1964 jasmine.Clock.assertInstalled(); +1965 jasmine.Clock.defaultFakeTimer.tick(millis); +1966 }, +1967 +1968 runFunctionsWithinRange: function(oldMillis, nowMillis) { +1969 jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); +1970 }, +1971 +1972 scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { +1973 jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); +1974 }, +1975 +1976 useMock: function() { +1977 var spec = jasmine.getEnv().currentSpec; +1978 spec.after(jasmine.Clock.uninstallMock); +1979 +1980 jasmine.Clock.installMock(); +1981 }, +1982 +1983 installMock: function() { +1984 jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; +1985 }, +1986 +1987 uninstallMock: function() { +1988 jasmine.Clock.assertInstalled(); +1989 jasmine.Clock.installed = jasmine.Clock.real; +1990 }, +1991 +1992 real: { +1993 setTimeout: window.setTimeout, +1994 clearTimeout: window.clearTimeout, +1995 setInterval: window.setInterval, +1996 clearInterval: window.clearInterval +1997 }, 1998 -1999 installed: null -2000 }; -2001 jasmine.Clock.installed = jasmine.Clock.real; -2002 -2003 window.setTimeout = function(funcToCall, millis) { -2004 return jasmine.Clock.installed.setTimeout.apply(this, arguments); -2005 }; -2006 -2007 window.setInterval = function(funcToCall, millis) { -2008 return jasmine.Clock.installed.setInterval.apply(this, arguments); -2009 }; -2010 -2011 window.clearTimeout = function(timeoutKey) { -2012 return jasmine.Clock.installed.clearTimeout.apply(this, arguments); -2013 }; -2014 -2015 window.clearInterval = function(timeoutKey) { -2016 return jasmine.Clock.installed.clearInterval.apply(this, arguments); -2017 }; -2018 -2019 \ No newline at end of file +1999 assertInstalled: function() { +2000 if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) { +2001 throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); +2002 } +2003 }, +2004 +2005 installed: null +2006 }; +2007 jasmine.Clock.installed = jasmine.Clock.real; +2008 +2009 window.setTimeout = function(funcToCall, millis) { +2010 return jasmine.Clock.installed.setTimeout.apply(this, arguments); +2011 }; +2012 +2013 window.setInterval = function(funcToCall, millis) { +2014 return jasmine.Clock.installed.setInterval.apply(this, arguments); +2015 }; +2016 +2017 window.clearTimeout = function(timeoutKey) { +2018 return jasmine.Clock.installed.clearTimeout.apply(this, arguments); +2019 }; +2020 +2021 window.clearInterval = function(timeoutKey) { +2022 return jasmine.Clock.installed.clearInterval.apply(this, arguments); +2023 }; +2024 +2025 \ No newline at end of file diff --git a/lib/jasmine-0.9.0.js b/lib/jasmine-0.9.0.js index 9017c45..537371d 100644 --- a/lib/jasmine-0.9.0.js +++ b/lib/jasmine-0.9.0.js @@ -517,7 +517,7 @@ jasmine.version_= { "major": 0, "minor": 9, "build": 0, - "revision": 1251902474 + "revision": 1252086971 }; /** * @namespace @@ -591,6 +591,8 @@ jasmine.Env = function() { this.reporter = new jasmine.MultiReporter(); + this.updateInterval = 0; + this.updateInterval = 0; this.lastUpdate = 0; this.specFilter = function() { @@ -1434,7 +1436,7 @@ jasmine.Queue.prototype.isRunning = function () { jasmine.Queue.prototype._next = function () { var self = this; - self.env.setTimeout(function () { + var doNext = function () { self.offset = 0; self.index++; if (self.index < self.blocks.length) { @@ -1444,7 +1446,15 @@ jasmine.Queue.prototype._next = function () { } else { self.finish(); } - }, 0); + }; + 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 () { diff --git a/spec/suites/ReporterSpec.js b/spec/suites/ReporterSpec.js index 4ceeccb..ad4e498 100644 --- a/spec/suites/ReporterSpec.js +++ b/spec/suites/ReporterSpec.js @@ -1,16 +1,10 @@ describe('jasmine.Reporter', function() { var env; - var fakeTimer; beforeEach(function() { env = new jasmine.Env(); - fakeTimer = new jasmine.FakeTimer(); - env.setTimeout = fakeTimer.setTimeout; - env.clearTimeout = fakeTimer.clearTimeout; - env.setInterval = fakeTimer.setInterval; - env.clearInterval = fakeTimer.clearInterval; }); it('should get called from the test runner', function() { @@ -57,7 +51,6 @@ describe('jasmine.Reporter', function() { var runner = env.currentRunner; runner.execute(); - fakeTimer.tick(0); expect(foo).toEqual(3); // 'foo was expected to be 3, was ' + foo); expect(bar).toEqual(2); // 'bar was expected to be 2, was ' + bar); diff --git a/spec/suites/RunnerSpec.js b/spec/suites/RunnerSpec.js index c2404ea..1618b9a 100644 --- a/spec/suites/RunnerSpec.js +++ b/spec/suites/RunnerSpec.js @@ -30,7 +30,6 @@ describe('RunnerTest', function() { }); env.currentRunner.execute(); - fakeTimer.tick(0); var runnerResults = env.currentRunner.getResults(); expect(runnerResults.totalCount).toEqual(2); @@ -57,8 +56,7 @@ describe('RunnerTest', function() { }); env.currentRunner.execute(); - fakeTimer.tick(0); - + var runnerResults = env.currentRunner.getResults(); expect(runnerResults.totalCount).toEqual(1); expect(runnerResults.passedCount).toEqual(0); @@ -83,7 +81,6 @@ describe('RunnerTest', function() { }); env.currentRunner.execute(); - fakeTimer.tick(0); var results = env.currentRunner.getResults(); expect(results.totalCount).toEqual(2); diff --git a/spec/suites/SpecRunningSpec.js b/spec/suites/SpecRunningSpec.js index 010756a..dc25e37 100644 --- a/spec/suites/SpecRunningSpec.js +++ b/spec/suites/SpecRunningSpec.js @@ -64,7 +64,6 @@ describe("jasmine spec running", function () { }); suite.execute(); - fakeTimer.tick(0); expect(specWithNoBody.description).toEqual('new spec'); @@ -117,7 +116,6 @@ describe("jasmine spec running", function () { expect(foo).toEqual(0); specWithRunsAndWaits.execute(); - fakeTimer.tick(0); expect(foo).toEqual(1); fakeTimer.tick(500); @@ -142,7 +140,6 @@ describe("jasmine spec running", function () { }); a_spec.execute(); - fakeTimer.tick(0); expect(a_spec.results.getItems().length).toEqual(1); // 'No call to waits(): Spec queue did not run all functions'; expect(a_spec.results.getItems()[0].passed()).toEqual(true); // 'No call to waits(): Queued expectation failed'; @@ -163,7 +160,6 @@ describe("jasmine spec running", function () { }); a_spec.execute(); - fakeTimer.tick(0); expect(a_spec.results.getItems().length).toEqual(0); @@ -362,7 +358,6 @@ describe("jasmine spec running", function () { }); suite.execute(); - fakeTimer.tick(0); expect(log).toEqual("specafter2after1"); }); @@ -394,7 +389,6 @@ describe("jasmine spec running", function () { }); suite.execute(); - fakeTimer.tick(0); expect(foo).toEqual(1); expect(bar).toEqual(0); @@ -428,7 +422,6 @@ describe("jasmine spec running", function () { }); suiteWithBefore.execute(); - fakeTimer.tick(0); var suite = suiteWithBefore; @@ -457,7 +450,6 @@ describe("jasmine spec running", function () { }); suiteWithAfter.execute(); - fakeTimer.tick(0); suite = suiteWithAfter; expect(suite.afterEach.length).toEqual(1); @@ -520,7 +512,6 @@ describe("jasmine spec running", function () { expect(baz).toEqual(0); expect(quux).toEqual(0); nested.execute(); - fakeTimer.tick(0); expect(foo).toEqual(1); expect(bar).toEqual(1); @@ -556,7 +547,6 @@ describe("jasmine spec running", function () { expect(reachedFirstWaitsFor).toEqual(false); waitsSuite.execute(); - fakeTimer.tick(0); expect(reachedFirstWaitsFor).toEqual(true); expect(foo).toEqual(0); @@ -640,7 +630,6 @@ describe("jasmine spec running", function () { expect(foo).toEqual(0); expect(bar).toEqual(0); suiteWithBefore.execute(); - fakeTimer.tick(0); expect(bar).toEqual(0); expect(foo).toEqual(1); @@ -682,7 +671,6 @@ describe("jasmine spec running", function () { expect(foo).toEqual(0); suiteWithAfter.execute(); - fakeTimer.tick(0); expect(firstSpecHasRun).toEqual(true); @@ -819,7 +807,6 @@ describe("jasmine spec running", function () { }); suite.execute(); - fakeTimer.tick(0); expect(report).toEqual("firstsecond"); var suiteResults = suite.getResults(); @@ -858,7 +845,6 @@ describe("jasmine spec running", function () { }); suite.execute(); - fakeTimer.tick(0); expect(report).toEqual("firstsecondthird"); // "all tests should run"); //After each errors should not go in spec results because it confuses the count. @@ -925,7 +911,6 @@ describe("jasmine spec running", function () { }); env.execute(); - fakeTimer.tick(0); var expected = [ @@ -987,7 +972,6 @@ describe("jasmine spec running", function () { }); env.execute(); - fakeTimer.tick(0); var runnerResults = env.currentRunner.getResults(); expect(runnerResults.totalCount).toEqual(3); @@ -1105,7 +1089,6 @@ describe("jasmine spec running", function () { }); suite.execute(); - fakeTimer.tick(0); expect(spec1Matcher.matcherForSuite("expected")).toEqual("matcherForSuite: actual: xxx; expected: expected"); expect(spec1Matcher.matcherForSpec("expected")).toEqual("matcherForSpec: actual: xxx; expected: expected"); diff --git a/src/Env.js b/src/Env.js index 37626ec..e0247e0 100644 --- a/src/Env.js +++ b/src/Env.js @@ -11,6 +11,8 @@ jasmine.Env = function() { this.reporter = new jasmine.MultiReporter(); + this.updateInterval = 0; + this.updateInterval = 0; this.lastUpdate = 0; this.specFilter = function() { diff --git a/src/Queue.js b/src/Queue.js index 5551c15..018021b 100644 --- a/src/Queue.js +++ b/src/Queue.js @@ -38,7 +38,7 @@ jasmine.Queue.prototype.isRunning = function () { jasmine.Queue.prototype._next = function () { var self = this; - self.env.setTimeout(function () { + var doNext = function () { self.offset = 0; self.index++; if (self.index < self.blocks.length) { @@ -48,7 +48,15 @@ jasmine.Queue.prototype._next = function () { } else { self.finish(); } - }, 0); + }; + 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 () {