From 50134eb1ac3627cda5f2ec2808fa3c7c5fc4a0db Mon Sep 17 00:00:00 2001 From: ragaskar Date: Tue, 1 Sep 2009 21:21:54 -0700 Subject: [PATCH] Fix 'doubled' test runs in test runner --- 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 | 2 +- doc/symbols/jasmine.Spec.html | 2 +- doc/symbols/jasmine.Spy.html | 2 +- doc/symbols/jasmine.Suite.html | 2 +- doc/symbols/jasmine.html | 2 +- doc/symbols/jasmine.util.html | 2 +- doc/symbols/src/lib_jasmine-0.9.0.js.html | 473 +++++++++++----------- lib/jasmine-0.9.0.js | 29 +- spec/suites/SpecRunningSpec.js | 1 + src/JsApiReporter.js | 18 +- src/Suite.js | 9 +- 20 files changed, 288 insertions(+), 272 deletions(-) diff --git a/doc/files.html b/doc/files.html index fc90155..ad54a31 100644 --- a/doc/files.html +++ b/doc/files.html @@ -258,7 +258,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 61f7b48..573ae9f 100644 --- a/doc/index.html +++ b/doc/index.html @@ -300,7 +300,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index 5db6c1d..3de8e73 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 Thu Aug 27 2009 22:21:54 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Block.html b/doc/symbols/jasmine.Block.html index b972e89..007e260 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Env.html b/doc/symbols/jasmine.Env.html index 16f2ded..5d10810 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.JsApiReporter.html b/doc/symbols/jasmine.JsApiReporter.html index 3d1baa1..05e9646 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.MultiReporter.html b/doc/symbols/jasmine.MultiReporter.html index 23f71bd..9cf8c9f 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index 9b3371d..5277921 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Reporter.html b/doc/symbols/jasmine.Reporter.html index 8670082..48c85b5 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index c09fd8b..2ba2a60 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -327,7 +327,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spec.html b/doc/symbols/jasmine.Spec.html index 1e38e66..9ddc595 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index 614a58b..7f6b4a2 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index f33a8d4..8c3f04e 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -345,7 +345,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index dfead0d..223627e 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 Thu Aug 27 2009 22:21:54 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index a9a7149..3c6c13e 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 Thu Aug 27 2009 22:21:55 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Sep 01 2009 21:19:29 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 fa9b546..885ecb7 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": 1 +520 "revision": 1251865107 521 }; 522 /** 523 * @namespace @@ -846,27 +846,27 @@ 839 840 jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { 841 this.started = true; -842 -843 for (var i = 0; i < runner.suites.length; i++) { -844 var suite = runner.suites[i]; +842 var suites = runner.getAllSuites(); +843 for (var i = 0; i < suites.length; i++) { +844 var suite = suites[i]; 845 this.suites.push(this.summarize_(suite)); 846 } 847 }; 848 849 jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { -850 var summary = { -851 id: suiteOrSpec.id, -852 name: suiteOrSpec.description, -853 type: suiteOrSpec instanceof jasmine.Suite ? 'suite' : 'spec', -854 children: [] -855 }; -856 -857 if (suiteOrSpec.specs) { -858 for (var i = 0; i < suiteOrSpec.specs.length; i++) { -859 summary.children.push(this.summarize_(suiteOrSpec.specs[i])); -860 } -861 } -862 +850 var isSuite = suiteOrSpec instanceof jasmine.Suite +851 var summary = { +852 id: suiteOrSpec.id, +853 name: suiteOrSpec.description, +854 type: isSuite ? 'suite' : 'spec', +855 children: [] +856 }; +857 if (isSuite) { +858 var specs = suiteOrSpec.getSpecs(); +859 for (var i = 0; i < specs.length; i++) { +860 summary.children.push(this.summarize_(specs[i])); +861 } +862 } 863 return summary; 864 }; 865 @@ -1794,228 +1794,233 @@ 1787 jasmine.Suite.prototype.add = function(block) { 1788 if (block instanceof jasmine.Suite) { 1789 this.env.currentRunner.addSuite(block); -1790 } -1791 this.specs.push(block); -1792 this.queue.add(block); -1793 }; -1794 -1795 jasmine.Suite.prototype.specCount = function(block) { -1796 return this.specs.length; -1797 }; -1798 -1799 jasmine.Suite.prototype.execute = function(onComplete) { -1800 var self = this; -1801 this.queue.start(function () { -1802 self.finish(onComplete); -1803 }); -1804 }; -1805 jasmine.WaitsBlock = function(env, timeout, spec) { -1806 this.timeout = timeout; -1807 jasmine.Block.call(this, env, null, spec); -1808 }; -1809 -1810 jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); -1811 -1812 jasmine.WaitsBlock.prototype.execute = function (onComplete) { -1813 this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); -1814 this.env.setTimeout(function () { -1815 onComplete(); -1816 }, this.timeout); -1817 }; -1818 jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { -1819 this.timeout = timeout; -1820 this.latchFunction = latchFunction; -1821 this.message = message; -1822 this.totalTimeSpentWaitingForLatch = 0; -1823 jasmine.Block.call(this, env, null, spec); -1824 }; -1825 -1826 jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); -1827 -1828 jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100; -1829 -1830 jasmine.WaitsForBlock.prototype.execute = function (onComplete) { -1831 var self = this; -1832 self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen')); -1833 var latchFunctionResult; -1834 try { -1835 latchFunctionResult = self.latchFunction.apply(self.spec); -1836 } catch (e) { -1837 self.fail(e); -1838 onComplete(); -1839 return; -1840 } -1841 -1842 if (latchFunctionResult) { +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.getSpecs = 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 } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) { -1845 var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen'); -1846 self.fail({ -1847 name: 'timeout', -1848 message: message -1849 }); -1850 self.spec._next(); -1851 } else { -1852 self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; -1853 self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); -1854 } -1855 }; -1856 // Mock setTimeout, clearTimeout -1857 // Contributed by Pivotal Computer Systems, www.pivotalsf.com -1858 -1859 jasmine.FakeTimer = function() { -1860 this.reset(); -1861 -1862 var self = this; -1863 self.setTimeout = function(funcToCall, millis) { -1864 self.timeoutsMade++; -1865 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); -1866 return self.timeoutsMade; -1867 }; -1868 -1869 self.setInterval = function(funcToCall, millis) { -1870 self.timeoutsMade++; -1871 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); -1872 return self.timeoutsMade; -1873 }; -1874 -1875 self.clearTimeout = function(timeoutKey) { -1876 self.scheduledFunctions[timeoutKey] = undefined; -1877 }; -1878 -1879 self.clearInterval = function(timeoutKey) { -1880 self.scheduledFunctions[timeoutKey] = undefined; -1881 }; -1882 -1883 }; -1884 -1885 jasmine.FakeTimer.prototype.reset = function() { -1886 this.timeoutsMade = 0; -1887 this.scheduledFunctions = {}; -1888 this.nowMillis = 0; -1889 }; -1890 -1891 jasmine.FakeTimer.prototype.tick = function(millis) { -1892 var oldMillis = this.nowMillis; -1893 var newMillis = oldMillis + millis; -1894 this.runFunctionsWithinRange(oldMillis, newMillis); -1895 this.nowMillis = newMillis; -1896 }; -1897 -1898 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { -1899 var scheduledFunc; -1900 var funcsToRun = []; -1901 for (var timeoutKey in this.scheduledFunctions) { -1902 scheduledFunc = this.scheduledFunctions[timeoutKey]; -1903 if (scheduledFunc != undefined && -1904 scheduledFunc.runAtMillis >= oldMillis && -1905 scheduledFunc.runAtMillis <= nowMillis) { -1906 funcsToRun.push(scheduledFunc); -1907 this.scheduledFunctions[timeoutKey] = undefined; -1908 } -1909 } -1910 -1911 if (funcsToRun.length > 0) { -1912 funcsToRun.sort(function(a, b) { -1913 return a.runAtMillis - b.runAtMillis; -1914 }); -1915 for (var i = 0; i < funcsToRun.length; ++i) { -1916 try { -1917 var funcToRun = funcsToRun[i]; -1918 this.nowMillis = funcToRun.runAtMillis; -1919 funcToRun.funcToCall(); -1920 if (funcToRun.recurring) { -1921 this.scheduleFunction(funcToRun.timeoutKey, -1922 funcToRun.funcToCall, -1923 funcToRun.millis, -1924 true); -1925 } -1926 } catch(e) { -1927 } -1928 } -1929 this.runFunctionsWithinRange(oldMillis, nowMillis); -1930 } -1931 }; -1932 -1933 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { -1934 this.scheduledFunctions[timeoutKey] = { -1935 runAtMillis: this.nowMillis + millis, -1936 funcToCall: funcToCall, -1937 recurring: recurring, -1938 timeoutKey: timeoutKey, -1939 millis: millis -1940 }; -1941 }; -1942 -1943 -1944 jasmine.Clock = { -1945 defaultFakeTimer: new jasmine.FakeTimer(), -1946 -1947 reset: function() { -1948 jasmine.Clock.assertInstalled(); -1949 jasmine.Clock.defaultFakeTimer.reset(); -1950 }, +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) { +1875 self.timeoutsMade++; +1876 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); +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 }; +1889 +1890 jasmine.FakeTimer.prototype.reset = function() { +1891 this.timeoutsMade = 0; +1892 this.scheduledFunctions = {}; +1893 this.nowMillis = 0; +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 tick: function(millis) { +1952 reset: function() { 1953 jasmine.Clock.assertInstalled(); -1954 jasmine.Clock.defaultFakeTimer.tick(millis); +1954 jasmine.Clock.defaultFakeTimer.reset(); 1955 }, 1956 -1957 runFunctionsWithinRange: function(oldMillis, nowMillis) { -1958 jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); -1959 }, -1960 -1961 scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { -1962 jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); -1963 }, -1964 -1965 useMock: function() { -1966 var spec = jasmine.getEnv().currentSpec; -1967 spec.after(jasmine.Clock.uninstallMock); -1968 -1969 jasmine.Clock.installMock(); -1970 }, -1971 -1972 installMock: function() { -1973 jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; -1974 }, -1975 -1976 uninstallMock: function() { -1977 jasmine.Clock.assertInstalled(); -1978 jasmine.Clock.installed = jasmine.Clock.real; +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 real: { -1982 setTimeout: window.setTimeout, -1983 clearTimeout: window.clearTimeout, -1984 setInterval: window.setInterval, -1985 clearInterval: window.clearInterval -1986 }, -1987 -1988 assertInstalled: function() { -1989 if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) { -1990 throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); -1991 } -1992 }, -1993 -1994 installed: null -1995 }; -1996 jasmine.Clock.installed = jasmine.Clock.real; -1997 -1998 window.setTimeout = function(funcToCall, millis) { -1999 return jasmine.Clock.installed.setTimeout.apply(this, arguments); +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 }, +1998 +1999 installed: null 2000 }; -2001 -2002 window.setInterval = function(funcToCall, millis) { -2003 return jasmine.Clock.installed.setInterval.apply(this, arguments); -2004 }; -2005 -2006 window.clearTimeout = function(timeoutKey) { -2007 return jasmine.Clock.installed.clearTimeout.apply(this, arguments); -2008 }; -2009 -2010 window.clearInterval = function(timeoutKey) { -2011 return jasmine.Clock.installed.clearInterval.apply(this, arguments); -2012 }; -2013 -2014 \ No newline at end of file +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 diff --git a/lib/jasmine-0.9.0.js b/lib/jasmine-0.9.0.js index e88b7a1..de0f1f9 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": 1251436915 + "revision": 1251865169 }; /** * @namespace @@ -839,27 +839,27 @@ jasmine.JsApiReporter = function() { jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { this.started = true; - - for (var i = 0; i < runner.suites.length; i++) { - var suite = runner.suites[i]; + var suites = runner.getAllSuites(); + for (var i = 0; i < suites.length; i++) { + var suite = suites[i]; this.suites.push(this.summarize_(suite)); } }; jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { + var isSuite = suiteOrSpec instanceof jasmine.Suite var summary = { id: suiteOrSpec.id, name: suiteOrSpec.description, - type: suiteOrSpec instanceof jasmine.Suite ? 'suite' : 'spec', + type: isSuite ? 'suite' : 'spec', children: [] }; - - if (suiteOrSpec.specs) { - for (var i = 0; i < suiteOrSpec.specs.length; i++) { - summary.children.push(this.summarize_(suiteOrSpec.specs[i])); + if (isSuite) { + var specs = suiteOrSpec.getSpecs(); + for (var i = 0; i < specs.length; i++) { + summary.children.push(this.summarize_(specs[i])); } } - return summary; }; @@ -1787,15 +1787,20 @@ jasmine.Suite.prototype.getResults = function() { jasmine.Suite.prototype.add = function(block) { if (block instanceof jasmine.Suite) { this.env.currentRunner.addSuite(block); + } else { + this.specs.push(block); } - this.specs.push(block); this.queue.add(block); }; -jasmine.Suite.prototype.specCount = function(block) { +jasmine.Suite.prototype.specCount = function() { return this.specs.length; }; +jasmine.Suite.prototype.getSpecs = function() { + return this.specs; +}; + jasmine.Suite.prototype.execute = function(onComplete) { var self = this; this.queue.start(function () { diff --git a/spec/suites/SpecRunningSpec.js b/spec/suites/SpecRunningSpec.js index 32a8b2d..010756a 100644 --- a/spec/suites/SpecRunningSpec.js +++ b/spec/suites/SpecRunningSpec.js @@ -489,6 +489,7 @@ describe("jasmine spec running", function () { }); it('nested suites', function () { + var foo = 0; var bar = 0; var baz = 0; diff --git a/src/JsApiReporter.js b/src/JsApiReporter.js index 1501123..a5da634 100644 --- a/src/JsApiReporter.js +++ b/src/JsApiReporter.js @@ -11,27 +11,27 @@ jasmine.JsApiReporter = function() { jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { this.started = true; - - for (var i = 0; i < runner.suites.length; i++) { - var suite = runner.suites[i]; + var suites = runner.getAllSuites(); + for (var i = 0; i < suites.length; i++) { + var suite = suites[i]; this.suites.push(this.summarize_(suite)); } }; jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { + var isSuite = suiteOrSpec instanceof jasmine.Suite var summary = { id: suiteOrSpec.id, name: suiteOrSpec.description, - type: suiteOrSpec instanceof jasmine.Suite ? 'suite' : 'spec', + type: isSuite ? 'suite' : 'spec', children: [] }; - - if (suiteOrSpec.specs) { - for (var i = 0; i < suiteOrSpec.specs.length; i++) { - summary.children.push(this.summarize_(suiteOrSpec.specs[i])); + if (isSuite) { + var specs = suiteOrSpec.getSpecs(); + for (var i = 0; i < specs.length; i++) { + summary.children.push(this.summarize_(specs[i])); } } - return summary; }; diff --git a/src/Suite.js b/src/Suite.js index 79fc5d7..b4d9f4b 100644 --- a/src/Suite.js +++ b/src/Suite.js @@ -52,15 +52,20 @@ jasmine.Suite.prototype.getResults = function() { jasmine.Suite.prototype.add = function(block) { if (block instanceof jasmine.Suite) { this.env.currentRunner.addSuite(block); + } else { + this.specs.push(block); } - this.specs.push(block); this.queue.add(block); }; -jasmine.Suite.prototype.specCount = function(block) { +jasmine.Suite.prototype.specCount = function() { return this.specs.length; }; +jasmine.Suite.prototype.getSpecs = function() { + return this.specs; +}; + jasmine.Suite.prototype.execute = function(onComplete) { var self = this; this.queue.start(function () {