diff options
| -rw-r--r-- | angularFiles.js | 6 | ||||
| -rw-r--r-- | lib/jasmine-1.0.1/index.js | 181 | ||||
| -rw-r--r-- | lib/jasmine-jstd-adapter/JasmineAdapter.js | 359 | ||||
| -rw-r--r-- | lib/jasmine/MIT.LICENSE (renamed from lib/jasmine-1.0.1/MIT.LICENSE) | 2 | ||||
| -rw-r--r-- | lib/jasmine/jasmine-html.js (renamed from lib/jasmine-1.0.1/jasmine-html.js) | 10 | ||||
| -rw-r--r-- | lib/jasmine/jasmine.css (renamed from lib/jasmine-1.0.1/jasmine.css) | 0 | ||||
| -rw-r--r-- | lib/jasmine/jasmine.js (renamed from lib/jasmine-1.0.1/jasmine.js) | 152 | ||||
| -rw-r--r-- | lib/jasmine/jasmine_favicon.png | bin | 0 -> 905 bytes | |||
| -rw-r--r-- | lib/jasmine/version.txt | 1 | ||||
| -rw-r--r-- | lib/jstestdriver/JsTestDriver.jar | bin | 3838338 -> 4290021 bytes | |||
| -rw-r--r-- | lib/jstestdriver/coverage.jar | bin | 2231066 -> 2231359 bytes | |||
| -rw-r--r-- | lib/jstestdriver/version.txt | 2 |
12 files changed, 296 insertions, 417 deletions
diff --git a/angularFiles.js b/angularFiles.js index ec45987e..3b4d91ee 100644 --- a/angularFiles.js +++ b/angularFiles.js @@ -57,7 +57,7 @@ angularFiles = { ], 'jstd': [ - 'lib/jasmine-1.0.1/jasmine.js', + 'lib/jasmine/jasmine.js', 'lib/jasmine-jstd-adapter/JasmineAdapter.js', 'lib/jquery/jquery.js', 'test/jquery_remove.js', @@ -94,7 +94,7 @@ angularFiles = { ], 'jstdPerf': [ - 'lib/jasmine-1.0.1/jasmine.js', + 'lib/jasmine/jasmine.js', 'lib/jasmine-jstd-adapter/JasmineAdapter.js', 'angularSrc', 'src/angular-mocks.js', @@ -110,7 +110,7 @@ angularFiles = { ], 'jstdJquery': [ - 'lib/jasmine-1.0.1/jasmine.js', + 'lib/jasmine/jasmine.js', 'lib/jasmine-jstd-adapter/JasmineAdapter.js', 'lib/jquery/jquery.js', 'test/jquery_alias.js', diff --git a/lib/jasmine-1.0.1/index.js b/lib/jasmine-1.0.1/index.js deleted file mode 100644 index 219f4238..00000000 --- a/lib/jasmine-1.0.1/index.js +++ /dev/null @@ -1,181 +0,0 @@ -var fs = require('fs'); -var sys = require('sys'); -var path = require('path'); -var vm = require('vm'); - -var filename = __dirname + '/jasmine.js'; -global.window = { - setTimeout: setTimeout, - clearTimeout: clearTimeout, - setInterval: setInterval, - clearInterval: clearInterval -}; -var src = fs.readFileSync(filename); -var jasmine = vm.runInThisContext(src + '\njasmine;', filename); -delete global.window; - -function noop(){} - -jasmine.executeSpecsInFolder = function(folder, done, isVerbose, showColors, matcher){ - var log = []; - var columnCounter = 0; - var start = 0; - var elapsed = 0; - var verbose = isVerbose || false; - var fileMatcher = new RegExp(matcher || "\.js$"); - var colors = showColors || false; - var specs = jasmine.getAllSpecFiles(folder, fileMatcher); - - var ansi = { - green: '\033[32m', - red: '\033[31m', - yellow: '\033[33m', - none: '\033[0m' - }; - - for (var i = 0, len = specs.length; i < len; ++i){ - var filename = specs[i]; - require(filename.replace(/\.*$/, "")); - } - - var jasmineEnv = jasmine.getEnv(); - jasmineEnv.reporter = { - log: function(str){ - }, - - reportSpecStarting: function(runner) { - }, - - reportRunnerStarting: function(runner) { - sys.puts('Started'); - start = Number(new Date); - }, - - reportSuiteResults: function(suite) { - var specResults = suite.results(); - var path = []; - while(suite) { - path.unshift(suite.description); - suite = suite.parentSuite; - } - var description = path.join(' '); - - if (verbose) - log.push('Spec ' + description); - - specResults.items_.forEach(function(spec){ - if (spec.failedCount > 0 && spec.description) { - if (!verbose) - log.push(description); - log.push(' it ' + spec.description); - spec.items_.forEach(function(result){ - log.push(' ' + result.trace.stack + '\n'); - }); - } - }); - }, - - reportSpecResults: function(spec) { - var result = spec.results(); - var msg = ''; - if (result.passed()) - { - msg = (colors) ? (ansi.green + '.' + ansi.none) : '.'; -// } else if (result.skipped) { TODO: Research why "result.skipped" returns false when "xit" is called on a spec? -// msg = (colors) ? (ansi.yellow + '*' + ansi.none) : '*'; - } else { - msg = (colors) ? (ansi.red + 'F' + ansi.none) : 'F'; - } - sys.print(msg); - if (columnCounter++ < 50) return; - columnCounter = 0; - sys.print('\n'); - }, - - - reportRunnerResults: function(runner) { - elapsed = (Number(new Date) - start) / 1000; - sys.puts('\n'); - log.forEach(function(log){ - sys.puts(log); - }); - sys.puts('Finished in ' + elapsed + ' seconds'); - - var summary = jasmine.printRunnerResults(runner); - if(colors) - { - if(runner.results().failedCount === 0 ) - sys.puts(ansi.green + summary + ansi.none); - else - sys.puts(ansi.red + summary + ansi.none); - } else { - sys.puts(summary); - } - (done||noop)(runner, log); - } - }; - jasmineEnv.execute(); -}; - -jasmine.getAllSpecFiles = function(dir, matcher){ - var specs = []; - - if (fs.statSync(dir).isFile() && dir.match(matcher)) { - specs.push(dir); - } else { - var files = fs.readdirSync(dir); - for (var i = 0, len = files.length; i < len; ++i){ - var filename = dir + '/' + files[i]; - if (fs.statSync(filename).isFile() && filename.match(matcher)){ - specs.push(filename); - }else if (fs.statSync(filename).isDirectory()){ - var subfiles = this.getAllSpecFiles(filename, matcher); - subfiles.forEach(function(result){ - specs.push(result); - }); - } - } - } - - return specs; -}; - -jasmine.printRunnerResults = function(runner){ - var results = runner.results(); - var suites = runner.suites(); - var msg = ''; - msg += suites.length + ' test' + ((suites.length === 1) ? '' : 's') + ', '; - msg += results.totalCount + ' assertion' + ((results.totalCount === 1) ? '' : 's') + ', '; - msg += results.failedCount + ' failure' + ((results.failedCount === 1) ? '' : 's') + '\n'; - return msg; -}; - -function now(){ - return new Date().getTime(); -} - -jasmine.asyncSpecWait = function(){ - var wait = jasmine.asyncSpecWait; - wait.start = now(); - wait.done = false; - (function innerWait(){ - waits(10); - runs(function() { - if (wait.start + wait.timeout < now()) { - expect('timeout waiting for spec').toBeNull(); - } else if (wait.done) { - wait.done = false; - } else { - innerWait(); - } - }); - })(); -}; -jasmine.asyncSpecWait.timeout = 4 * 1000; -jasmine.asyncSpecDone = function(){ - jasmine.asyncSpecWait.done = true; -}; - -for ( var key in jasmine) { - exports[key] = jasmine[key]; -}
\ No newline at end of file diff --git a/lib/jasmine-jstd-adapter/JasmineAdapter.js b/lib/jasmine-jstd-adapter/JasmineAdapter.js index ba33bb9d..370de8b7 100644 --- a/lib/jasmine-jstd-adapter/JasmineAdapter.js +++ b/lib/jasmine-jstd-adapter/JasmineAdapter.js @@ -1,186 +1,189 @@ /** * @fileoverview Jasmine JsTestDriver Adapter. * @author misko@hevery.com (Misko Hevery) + * @author olmo.maldonado@gmail.com (Olmo Maldonado) */ -(function(window) { - var rootDescribes = new Describes(window); - var describePath = []; - rootDescribes.collectMode(); - - var jasmineTest = TestCase('Jasmine Adapter Tests', null, 'jasmine test case'); - - var jasminePlugin = { - name:'jasmine', - runTestConfiguration: function(testRunConfiguration, onTestDone, onTestRunConfigurationComplete){ - if (testRunConfiguration.testCaseInfo_.template_ !== jasmineTest) return; - - var jasmineEnv = jasmine.currentEnv_ = new jasmine.Env(); - rootDescribes.playback(); - var specLog = jstestdriver.console.log_ = []; - var start; - jasmineEnv.specFilter = function(spec) { - return rootDescribes.isExclusive(spec); - }; - jasmineEnv.reporter = { - log: function(str){ - specLog.push(str); - }, - - reportRunnerStarting: function(runner) { }, - - reportSpecStarting: function(spec) { - specLog = jstestdriver.console.log_ = []; - start = new Date().getTime(); - }, - - reportSpecResults: function(spec) { - var suite = spec.suite; - var results = spec.results(); - if (results.skipped) return; - var end = new Date().getTime(); - var messages = []; - var resultItems = results.getItems(); - var state = 'passed'; - for ( var i = 0; i < resultItems.length; i++) { - if (!resultItems[i].passed()) { - state = resultItems[i].message.match(/AssertionError:/) ? 'error' : 'failed'; - messages.push({ - message: resultItems[i].toString(), - name: resultItems[i].trace.name, - stack: formatStack(resultItems[i].trace.stack) - }); - } - } - onTestDone( - new jstestdriver.TestResult( - suite.getFullName(), - spec.description, - state, - jstestdriver.angular.toJson(messages), - specLog.join('\n'), - end - start)); - }, - - reportSuiteResults: function(suite) {}, - - reportRunnerResults: function(runner) { - onTestRunConfigurationComplete(); - } - }; - jasmineEnv.execute(); - return true; - }, - onTestsFinish: function(){ - jasmine.currentEnv_ = null; - rootDescribes.collectMode(); - } - }; - jstestdriver.pluginRegistrar.register(jasminePlugin); - - function formatStack(stack) { - var lines = (stack||'').split(/\r?\n/); - var frames = []; - for (i = 0; i < lines.length; i++) { - if (!lines[i].match(/\/jasmine[\.-]/)) { - frames.push(lines[i].replace(/https?:\/\/\w+(:\d+)?\/test\//, '').replace(/^\s*/, ' ')); - } - } - return frames.join('\n'); - } - - function noop(){} - function Describes(window){ - var describes = {}; - var beforeEachs = {}; - var afterEachs = {}; - // Here we store: - // 0: everyone runs - // 1: run everything under ddescribe - // 2: run only iits (ignore ddescribe) - var exclusive = 0; - var collectMode = true; - intercept('describe', describes); - intercept('xdescribe', describes); - intercept('beforeEach', beforeEachs); - intercept('afterEach', afterEachs); - - function intercept(functionName, collection){ - window[functionName] = function(desc, fn){ - if (collectMode) { - collection[desc] = function(){ - jasmine.getEnv()[functionName](desc, fn); - }; - } else { - jasmine.getEnv()[functionName](desc, fn); - } - }; - } - window.ddescribe = function(name, fn){ - if (exclusive < 1) { - exclusive = 1; // run ddescribe only - } - window.describe(name, function(){ - var oldIt = window.it; - window.it = function(name, fn){ - fn.exclusive = 1; // run anything under ddescribe - jasmine.getEnv().it(name, fn); - }; - try { - fn.call(this); - } finally { - window.it = oldIt; - }; - }); - }; - window.iit = function(name, fn){ - exclusive = fn.exclusive = 2; // run only iits - jasmine.getEnv().it(name, fn); - }; - - - this.collectMode = function() { - collectMode = true; - exclusive = 0; // run everything - }; - this.playback = function(){ - collectMode = false; - playback(beforeEachs); - playback(afterEachs); - playback(describes); - - function playback(set) { - for ( var name in set) { - set[name](); - } - } - }; - - this.isExclusive = function(spec) { - if (exclusive) { - var blocks = spec.queue.blocks; - for ( var i = 0; i < blocks.length; i++) { - if (blocks[i].func.exclusive >= exclusive) { - return true; - } - } - return false; - } - return true; - }; - } - -})(window); +(function(){ + + +var Env = function(onTestDone, onComplete){ + jasmine.Env.call(this); + + this.specFilter = function(spec){ + if (!this.exclusive) return true; + var blocks = spec.queue.blocks, l = blocks.length; + for (var i = 0; i < l; i++) if (blocks[i].func.exclusive >= this.exclusive) return true; + return false; + }; + + this.reporter = new Reporter(onTestDone, onComplete); +}; +jasmine.util.inherit(Env, jasmine.Env); + +// Here we store: +// 0: everyone runs +// 1: run everything under ddescribe +// 2: run only iits (ignore ddescribe) +Env.prototype.exclusive = 0; + + +Env.prototype.execute = function(){ + collectMode = false; + playback(); + jasmine.Env.prototype.execute.call(this); +}; + + +var Reporter = function(onTestDone, onComplete){ + this.onTestDone = onTestDone; + this.onComplete = onComplete; + this.reset(); +}; +jasmine.util.inherit(Reporter, jasmine.Reporter); + + +Reporter.formatStack = function(stack) { + var line, lines = (stack || '').split(/\r?\n/), l = lines.length, frames = []; + for (var i = 0; i < l; i++){ + line = lines[i]; + if (line.match(/\/jasmine[\.-]/)) continue; + frames.push(line.replace(/https?:\/\/\w+(:\d+)?\/test\//, '').replace(/^\s*/, ' ')); + } + return frames.join('\n'); +}; + + +Reporter.prototype.reset = function(){ + this.specLog = jstestdriver.console.log_ = []; +}; + + +Reporter.prototype.log = function(str){ + this.specLog.push(str); +}; + + +Reporter.prototype.reportSpecStarting = function(){ + this.reset(); + this.start = +new Date(); +}; + + +Reporter.prototype.reportSpecResults = function(spec){ + var elapsed = +new Date() - this.start, results = spec.results(); + + if (results.skipped) return; + + var item, state = 'passed', items = results.getItems(), l = items.length, messages = []; + for (var i = 0; i < l; i++){ + item = items[i]; + if (item.passed()) continue; + state = (item.message.indexOf('AssertionError:') != -1) ? 'error' : 'failed'; + messages.push({ + message: item + '', + name: item.trace.name, + stack: Reporter.formatStack(item.trace.stack) + }); + } + + this.onTestDone(new jstestdriver.TestResult( + spec.suite.getFullName(), + spec.description, + state, + jstestdriver.angular.toJson(messages), + this.specLog.join('\n'), + elapsed + )); +}; + + +Reporter.prototype.reportRunnerResults = function(){ + this.onComplete(); +}; + + +var collectMode = true, intercepted = {}; + +describe = intercept('describe'); +beforeEach = intercept('beforeEach'); +afterEach = intercept('afterEach'); + +var JASMINE_TYPE = 'jasmine test case'; +TestCase('Jasmine Adapter Tests', null, JASMINE_TYPE); + +jstestdriver.pluginRegistrar.register({ + + name: 'jasmine', + + getTestRunsConfigurationFor: function(testCaseInfos, expressions, testRunsConfiguration) { + for (var i = 0; i < testCaseInfos.length; i++) { + if (testCaseInfos[i].getType() == JASMINE_TYPE) { + testRunsConfiguration.push(new jstestdriver.TestRunConfiguration(testCaseInfos[i], [])); + } + } + return false; // allow other TestCases to be collected. + }, + + runTestConfiguration: function(config, onTestDone, onComplete){ + if (config.getTestCaseInfo().getType() != JASMINE_TYPE) return false; + (jasmine.currentEnv_ = new Env(onTestDone, onComplete)).execute(); + return true; + }, + + onTestsFinish: function(){ + jasmine.currentEnv_ = null; + collectMode = true; + } + +}); + +function intercept(method){ + var bucket = intercepted[method] = [], method = window[method]; + return function(desc, fn){ + if (collectMode) bucket.push(function(){ method(desc, fn); }); + else method(desc, fn); + }; +} + +function playback(){ + for (var method in intercepted){ + var bucket = intercepted[method]; + for (var i = 0, l = bucket.length; i < l; i++) bucket[i](); + } +} + +})(); + +var ddescribe = function(name, fn){ + var env = jasmine.getEnv(); + if (!env.exclusive) env.exclusive = 1; // run ddescribe only + describe(name, function(){ + var oldIt = it; + it = function(name, fn){ + fn.exclusive = 1; // run anything under ddescribe + env.it(name, fn); + }; + + try { + fn.call(this); + } finally { + it = oldIt; + }; + }); +}; + +var iit = function(name, fn){ + var env = jasmine.getEnv(); + env.exclusive = fn.exclusive = 2; // run only iits + env.it(name, fn); +}; // Patch Jasmine for proper stack traces jasmine.Spec.prototype.fail = function (e) { - var expectationResult = new jasmine.ExpectationResult({ - passed: false, - message: e ? jasmine.util.formatException(e) : 'Exception' - }); - // PATCH - if (e) { - expectationResult.trace = e; - } - this.results_.addResult(expectationResult); + var result = new jasmine.ExpectationResult({ + passed: false, + message: e ? jasmine.util.formatException(e) : 'Exception' + }); + if(e) result.trace = e; + this.results_.addResult(result); }; - diff --git a/lib/jasmine-1.0.1/MIT.LICENSE b/lib/jasmine/MIT.LICENSE index 1eb9b49e..7c435baa 100644 --- a/lib/jasmine-1.0.1/MIT.LICENSE +++ b/lib/jasmine/MIT.LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2008-2010 Pivotal Labs +Copyright (c) 2008-2011 Pivotal Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/lib/jasmine-1.0.1/jasmine-html.js b/lib/jasmine/jasmine-html.js index 81402b9c..73834010 100644 --- a/lib/jasmine-1.0.1/jasmine-html.js +++ b/lib/jasmine/jasmine-html.js @@ -34,7 +34,7 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) { this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' }, this.createDom('div', { className: 'banner' }, this.createDom('div', { className: 'logo' }, - this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"), + this.createDom('span', { className: 'title' }, "Jasmine"), this.createDom('span', { className: 'version' }, runner.env.versionString())), this.createDom('div', { className: 'options' }, "Show ", @@ -110,7 +110,7 @@ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) { jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { var results = suite.results(); var status = results.passed() ? 'passed' : 'failed'; - if (results.totalCount == 0) { // todo: change this to check results.skipped + if (results.totalCount === 0) { // todo: change this to check results.skipped status = 'skipped'; } this.suiteDivs[suite.id].className += " " + status; @@ -183,6 +183,8 @@ jasmine.TrivialReporter.prototype.specFilter = function(spec) { paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); } - if (!paramMap["spec"]) return true; - return spec.getFullName().indexOf(paramMap["spec"]) == 0; + if (!paramMap.spec) { + return true; + } + return spec.getFullName().indexOf(paramMap.spec) === 0; }; diff --git a/lib/jasmine-1.0.1/jasmine.css b/lib/jasmine/jasmine.css index 6583fe7c..6583fe7c 100644 --- a/lib/jasmine-1.0.1/jasmine.css +++ b/lib/jasmine/jasmine.css diff --git a/lib/jasmine-1.0.1/jasmine.js b/lib/jasmine/jasmine.js index be34ecbf..c3d2dc7d 100644 --- a/lib/jasmine-1.0.1/jasmine.js +++ b/lib/jasmine/jasmine.js @@ -1,10 +1,12 @@ +var isCommonJS = typeof window == "undefined"; + /** * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework. * * @namespace */ var jasmine = {}; - +if (isCommonJS) exports.jasmine = jasmine; /** * @private */ @@ -21,6 +23,12 @@ jasmine.unimplementedMethod_ = function() { jasmine.undefined = jasmine.___undefined___; /** + * Show diagnostic messages in the console if set to true + * + */ +jasmine.VERBOSE = false; + +/** * Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). Small values here may result in slow test running. Zero means no updates until all tests have completed. * */ @@ -72,7 +80,7 @@ jasmine.MessageResult = function(values) { jasmine.MessageResult.prototype.toString = function() { var text = ""; - for(var i = 0; i < this.values.length; i++) { + for (var i = 0; i < this.values.length; i++) { if (i > 0) text += " "; if (jasmine.isString_(this.values[i])) { text += this.values[i]; @@ -89,9 +97,10 @@ jasmine.ExpectationResult = function(params) { this.passed_ = params.passed; this.expected = params.expected; this.actual = params.actual; - this.message = this.passed_ ? 'Passed.' : params.message; - this.trace = this.passed_ ? '' : new Error(this.message); + + var trace = (params.trace || new Error(this.message)); + this.trace = this.passed_ ? '' : trace; }; jasmine.ExpectationResult.prototype.toString = function () { @@ -106,7 +115,8 @@ jasmine.ExpectationResult.prototype.passed = function () { * Getter for the Jasmine environment. Ensures one gets created */ jasmine.getEnv = function() { - return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); + var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); + return env; }; /** @@ -116,7 +126,7 @@ jasmine.getEnv = function() { * @returns {Boolean} */ jasmine.isArray_ = function(value) { - return jasmine.isA_("Array", value); + return jasmine.isA_("Array", value); }; /** @@ -169,7 +179,7 @@ jasmine.pp = function(value) { * @returns {Boolean} */ jasmine.isDomNode = function(obj) { - return obj['nodeType'] > 0; + return obj.nodeType > 0; }; /** @@ -405,7 +415,7 @@ jasmine.isSpy = function(putativeSpy) { * @param {Array} methodNames array of names of methods to make spies */ jasmine.createSpyObj = function(baseName, methodNames) { - if (!jasmine.isArray_(methodNames) || methodNames.length == 0) { + if (!jasmine.isArray_(methodNames) || methodNames.length === 0) { throw new Error('createSpyObj requires a non-empty array of method names to create spies for'); } var obj = {}; @@ -443,6 +453,7 @@ jasmine.log = function() { var spyOn = function(obj, methodName) { return jasmine.getEnv().currentSpec.spyOn(obj, methodName); }; +if (isCommonJS) exports.spyOn = spyOn; /** * Creates a Jasmine spec that will be added to the current suite. @@ -460,6 +471,7 @@ var spyOn = function(obj, methodName) { var it = function(desc, func) { return jasmine.getEnv().it(desc, func); }; +if (isCommonJS) exports.it = it; /** * Creates a <em>disabled</em> Jasmine spec. @@ -472,6 +484,7 @@ var it = function(desc, func) { var xit = function(desc, func) { return jasmine.getEnv().xit(desc, func); }; +if (isCommonJS) exports.xit = xit; /** * Starts a chain for a Jasmine expectation. @@ -484,6 +497,7 @@ var xit = function(desc, func) { var expect = function(actual) { return jasmine.getEnv().currentSpec.expect(actual); }; +if (isCommonJS) exports.expect = expect; /** * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. @@ -493,6 +507,7 @@ var expect = function(actual) { var runs = function(func) { jasmine.getEnv().currentSpec.runs(func); }; +if (isCommonJS) exports.runs = runs; /** * Waits a fixed time period before moving to the next block. @@ -503,6 +518,7 @@ var runs = function(func) { var waits = function(timeout) { jasmine.getEnv().currentSpec.waits(timeout); }; +if (isCommonJS) exports.waits = waits; /** * Waits for the latchFunction to return true before proceeding to the next block. @@ -514,6 +530,7 @@ var waits = function(timeout) { var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) { jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments); }; +if (isCommonJS) exports.waitsFor = waitsFor; /** * A function that is called before each spec in a suite. @@ -525,6 +542,7 @@ var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout var beforeEach = function(beforeEachFunction) { jasmine.getEnv().beforeEach(beforeEachFunction); }; +if (isCommonJS) exports.beforeEach = beforeEach; /** * A function that is called after each spec in a suite. @@ -536,6 +554,7 @@ var beforeEach = function(beforeEachFunction) { var afterEach = function(afterEachFunction) { jasmine.getEnv().afterEach(afterEachFunction); }; +if (isCommonJS) exports.afterEach = afterEach; /** * Defines a suite of specifications. @@ -555,6 +574,7 @@ var afterEach = function(afterEachFunction) { var describe = function(description, specDefinitions) { return jasmine.getEnv().describe(description, specDefinitions); }; +if (isCommonJS) exports.describe = describe; /** * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. @@ -565,27 +585,35 @@ var describe = function(description, specDefinitions) { var xdescribe = function(description, specDefinitions) { return jasmine.getEnv().xdescribe(description, specDefinitions); }; +if (isCommonJS) exports.xdescribe = xdescribe; // Provide the XMLHttpRequest class for IE 5.x-6.x: jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { - try { - return new ActiveXObject("Msxml2.XMLHTTP.6.0"); - } catch(e) { - } - try { - return new ActiveXObject("Msxml2.XMLHTTP.3.0"); - } catch(e) { - } - try { - return new ActiveXObject("Msxml2.XMLHTTP"); - } catch(e) { - } - try { - return new ActiveXObject("Microsoft.XMLHTTP"); - } catch(e) { + function tryIt(f) { + try { + return f(); + } catch(e) { + } + return null; } - throw new Error("This browser does not support XMLHttpRequest."); + + var xhr = tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP.6.0"); + }) || + tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP.3.0"); + }) || + tryIt(function() { + return new ActiveXObject("Msxml2.XMLHTTP"); + }) || + tryIt(function() { + return new ActiveXObject("Microsoft.XMLHTTP"); + }); + + if (!xhr) throw new Error("This browser does not support XMLHttpRequest."); + + return xhr; } : XMLHttpRequest; /** * @namespace @@ -606,7 +634,7 @@ jasmine.util.inherit = function(childClass, parentClass) { var subclass = function() { }; subclass.prototype = parentClass.prototype; - childClass.prototype = new subclass; + childClass.prototype = new subclass(); }; jasmine.util.formatException = function(e) { @@ -707,12 +735,17 @@ jasmine.Env.prototype.version = function () { * @returns string containing jasmine version build info, if set. */ jasmine.Env.prototype.versionString = function() { - if (jasmine.version_) { - var version = this.version(); - return version.major + "." + version.minor + "." + version.build + " revision " + version.revision; - } else { + if (!jasmine.version_) { return "version unknown"; } + + var version = this.version(); + var versionString = version.major + "." + version.minor + "." + version.build; + if (version.release_candidate) { + versionString += ".rc" + version.release_candidate; + } + versionString += " revision " + version.revision; + return versionString; }; /** @@ -760,14 +793,14 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) { declarationError = e; } - this.currentSuite = parentSuite; - if (declarationError) { this.it("encountered a declaration exception", function() { throw declarationError; }); } + this.currentSuite = parentSuite; + return suite; }; @@ -828,7 +861,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal b.__Jasmine_been_here_before__ = a; var hasKey = function(obj, keyName) { - return obj != null && obj[keyName] !== jasmine.undefined; + return obj !== null && obj[keyName] !== jasmine.undefined; }; for (var property in b) { @@ -854,7 +887,7 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal delete a.__Jasmine_been_here_before__; delete b.__Jasmine_been_here_before__; - return (mismatchKeys.length == 0 && mismatchValues.length == 0); + return (mismatchKeys.length === 0 && mismatchValues.length === 0); }; jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { @@ -1302,16 +1335,16 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() { throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); } this.message = function() { - if (this.actual.callCount == 0) { + if (this.actual.callCount === 0) { // todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw] return [ - "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.", - "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was." + "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.", + "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was." ]; } else { return [ - "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall), - "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall) + "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall), + "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall) ]; } }; @@ -1333,7 +1366,7 @@ jasmine.Matchers.prototype.wasNotCalledWith = function() { return [ "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was", "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was" - ] + ]; }; return !this.env.contains_(this.actual.argsForCall, expectedArgs); @@ -1367,6 +1400,23 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { }; /** + * Matcher that checks that the expected item is equal to the actual item + * up to a given level of decimal precision (default 2). + * + * @param {Number} expected + * @param {Number} precision + */ +jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) { + if (!(precision === 0)) { + precision = precision || 2; + } + var multiplier = Math.pow(10, precision); + var actual = Math.round(this.actual * multiplier); + expected = Math.round(expected * multiplier); + return expected == actual; +}; + +/** * Matcher that checks that the expected exception was thrown by the actual. * * @param {String} expected @@ -1390,7 +1440,7 @@ jasmine.Matchers.prototype.toThrow = function(expected) { this.message = function() { if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { - return ["Expected function " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", exception.message || exception].join(' '); + return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' '); } else { return "Expected function to throw an exception."; } @@ -1602,7 +1652,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) { jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { for (var property in obj) { if (property == '__Jasmine_been_here_before__') continue; - fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false); + fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && + obj.__lookupGetter__(property) !== null) : false); } }; @@ -1962,7 +2013,8 @@ jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessag jasmine.Spec.prototype.fail = function (e) { var expectationResult = new jasmine.ExpectationResult({ passed: false, - message: e ? jasmine.util.formatException(e) : 'Exception' + message: e ? jasmine.util.formatException(e) : 'Exception', + trace: { stack: e.stack } }); this.results_.addResult(expectationResult); }; @@ -2172,7 +2224,9 @@ jasmine.WaitsBlock = function(env, timeout, spec) { jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); jasmine.WaitsBlock.prototype.execute = function (onComplete) { - this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); + if (jasmine.VERBOSE) { + this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); + } this.env.setTimeout(function () { onComplete(); }, this.timeout); @@ -2200,8 +2254,9 @@ jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10; jasmine.WaitsForBlock.prototype.execute = function(onComplete) { - // (i): disabled this log since its annoying - //this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen')); + if (jasmine.VERBOSE) { + this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen')); + } var latchFunctionResult; try { latchFunctionResult = this.latchFunction.apply(this.spec); @@ -2413,10 +2468,9 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) { } }; - jasmine.version_= { "major": 1, - "minor": 0, - "build": 1, - "revision": 1286311016 + "minor": 1, + "build": 0, + "revision": 1315677058 }; diff --git a/lib/jasmine/jasmine_favicon.png b/lib/jasmine/jasmine_favicon.png Binary files differnew file mode 100644 index 00000000..218f3b43 --- /dev/null +++ b/lib/jasmine/jasmine_favicon.png diff --git a/lib/jasmine/version.txt b/lib/jasmine/version.txt new file mode 100644 index 00000000..9084fa2f --- /dev/null +++ b/lib/jasmine/version.txt @@ -0,0 +1 @@ +1.1.0 diff --git a/lib/jstestdriver/JsTestDriver.jar b/lib/jstestdriver/JsTestDriver.jar Binary files differindex 1787c640..39b00543 100644 --- a/lib/jstestdriver/JsTestDriver.jar +++ b/lib/jstestdriver/JsTestDriver.jar diff --git a/lib/jstestdriver/coverage.jar b/lib/jstestdriver/coverage.jar Binary files differindex 1271ef84..4ebde6c8 100644 --- a/lib/jstestdriver/coverage.jar +++ b/lib/jstestdriver/coverage.jar diff --git a/lib/jstestdriver/version.txt b/lib/jstestdriver/version.txt index 1892b926..a7084f98 100644 --- a/lib/jstestdriver/version.txt +++ b/lib/jstestdriver/version.txt @@ -1 +1 @@ -1.3.2 +1.3.3c |
