Build distribution for 2.0.0-rc5 and associated standalone distribution

This commit is contained in:
Sheel Choksi
2013-10-29 14:01:40 -07:00
parent 69549a6ff3
commit 40e3020fdc
6 changed files with 255 additions and 282 deletions

BIN
dist/jasmine-standalone-2.0.0-rc5.zip vendored Normal file

Binary file not shown.

View File

@@ -91,10 +91,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return env.spyOn(obj, methodName); return env.spyOn(obj, methodName);
}, },
addCustomEqualityTester: function(tester) {
env.addCustomEqualityTester(tester);
},
jsApiReporter: new jasmine.JsApiReporter({ jsApiReporter: new jasmine.JsApiReporter({
timer: new jasmine.Timer() timer: new jasmine.Timer()
}) })
@@ -149,7 +145,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
var htmlReporter = new jasmine.HtmlReporter({ var htmlReporter = new jasmine.HtmlReporter({
env: env, env: env,
queryString: queryString,
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); }, onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
getContainer: function() { return document.body; }, getContainer: function() { return document.body; },
createElement: function() { return document.createElement.apply(document, arguments); }, createElement: function() { return document.createElement.apply(document, arguments); },
@@ -197,4 +192,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
return destination; return destination;
} }
}()); }());

View File

@@ -26,11 +26,12 @@ jasmineRequire.html = function(j$) {
j$.QueryString = jasmineRequire.QueryString(); j$.QueryString = jasmineRequire.QueryString();
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
}; };
jasmineRequire.HtmlReporter = function(j$) { jasmineRequire.HtmlReporter = function(j$) {
var noopTimer = { var noopTimer = {
start: function(){}, start: function() {},
elapsed: function(){ return 0; } elapsed: function() { return 0; }
}; };
function HtmlReporter(options) { function HtmlReporter(options) {
@@ -101,7 +102,8 @@ jasmineRequire.HtmlReporter = function(j$) {
symbols.appendChild(createDom("li", { symbols.appendChild(createDom("li", {
className: result.status, className: result.status,
id: "spec_" + result.id, id: "spec_" + result.id,
title: result.fullName} title: result.fullName
}
)); ));
if (result.status == "failed") { if (result.status == "failed") {
@@ -307,6 +309,7 @@ jasmineRequire.ResultsNode = function() {
return ResultsNode; return ResultsNode;
}; };
jasmineRequire.QueryString = function() { jasmineRequire.QueryString = function() {
function QueryString(options) { function QueryString(options) {

View File

@@ -142,18 +142,18 @@ getJasmineRequireObj().base = function(j$) {
j$.createSpy = function(name, originalFn) { j$.createSpy = function(name, originalFn) {
var spyStrategy = new j$.SpyStrategy({ var spyStrategy = new j$.SpyStrategy({
name: name, name: name,
fn: originalFn, fn: originalFn,
getSpy: function() { return spy; } getSpy: function() { return spy; }
}), }),
callTracker = new j$.CallTracker(), callTracker = new j$.CallTracker(),
spy = function() { spy = function() {
callTracker.track({ callTracker.track({
object: this, object: this,
args: Array.prototype.slice.apply(arguments) args: Array.prototype.slice.apply(arguments)
}); });
return spyStrategy.exec.apply(this, arguments); return spyStrategy.exec.apply(this, arguments);
}; };
for (var prop in originalFn) { for (var prop in originalFn) {
if (prop === 'and' || prop === 'calls') { if (prop === 'and' || prop === 'calls') {
@@ -174,7 +174,7 @@ getJasmineRequireObj().base = function(j$) {
return false; return false;
} }
return putativeSpy.and instanceof j$.SpyStrategy && return putativeSpy.and instanceof j$.SpyStrategy &&
putativeSpy.calls instanceof j$.CallTracker; putativeSpy.calls instanceof j$.CallTracker;
}; };
j$.createSpyObj = function(baseName, methodNames) { j$.createSpyObj = function(baseName, methodNames) {
@@ -194,14 +194,16 @@ getJasmineRequireObj().util = function() {
var util = {}; var util = {};
util.inherit = function(childClass, parentClass) { util.inherit = function(childClass, parentClass) {
var subclass = function() { var Subclass = function() {
}; };
subclass.prototype = parentClass.prototype; Subclass.prototype = parentClass.prototype;
childClass.prototype = new subclass(); childClass.prototype = new Subclass();
}; };
util.htmlEscape = function(str) { util.htmlEscape = function(str) {
if (!str) return str; if (!str) {
return str;
}
return str.replace(/&/g, '&') return str.replace(/&/g, '&')
.replace(/</g, '&lt;') .replace(/</g, '&lt;')
.replace(/>/g, '&gt;'); .replace(/>/g, '&gt;');
@@ -209,7 +211,9 @@ getJasmineRequireObj().util = function() {
util.argsToArray = function(args) { util.argsToArray = function(args) {
var arrayOfArgs = []; var arrayOfArgs = [];
for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]); for (var i = 0; i < args.length; i++) {
arrayOfArgs.push(args[i]);
}
return arrayOfArgs; return arrayOfArgs;
}; };
@@ -222,7 +226,6 @@ getJasmineRequireObj().util = function() {
getJasmineRequireObj().Spec = function(j$) { getJasmineRequireObj().Spec = function(j$) {
function Spec(attrs) { function Spec(attrs) {
this.encounteredExpectations = false;
this.expectationFactory = attrs.expectationFactory; this.expectationFactory = attrs.expectationFactory;
this.resultCallback = attrs.resultCallback || function() {}; this.resultCallback = attrs.resultCallback || function() {};
this.id = attrs.id; this.id = attrs.id;
@@ -248,13 +251,11 @@ getJasmineRequireObj().Spec = function(j$) {
id: this.id, id: this.id,
description: this.description, description: this.description,
fullName: this.getFullName(), fullName: this.getFullName(),
status: this.status(),
failedExpectations: [] failedExpectations: []
}; };
} }
Spec.prototype.addExpectationResult = function(passed, data) { Spec.prototype.addExpectationResult = function(passed, data) {
this.encounteredExpectations = true;
if (passed) { if (passed) {
return; return;
} }
@@ -278,7 +279,7 @@ getJasmineRequireObj().Spec = function(j$) {
function timeoutable(fn) { function timeoutable(fn) {
return function(done) { return function(done) {
var timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() { var timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
onException(new Error('timeout')); onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'));
done(); done();
}, j$.DEFAULT_TIMEOUT_INTERVAL]]); }, j$.DEFAULT_TIMEOUT_INTERVAL]]);
@@ -292,8 +293,8 @@ getJasmineRequireObj().Spec = function(j$) {
} }
var befores = this.beforeFns() || [], var befores = this.beforeFns() || [],
afters = this.afterFns() || [], afters = this.afterFns() || [],
thisOne = (this.fn.length) ? timeoutable(this.fn) : this.fn; thisOne = (this.fn.length) ? timeoutable(this.fn) : this.fn;
var allFns = befores.concat(thisOne).concat(afters); var allFns = befores.concat(thisOne).concat(afters);
this.queueRunner({ this.queueRunner({
@@ -303,18 +304,18 @@ getJasmineRequireObj().Spec = function(j$) {
}); });
function onException(e) { function onException(e) {
if (Spec.isPendingSpecException(e)) { if (Spec.isPendingSpecException(e)) {
self.pend(); self.pend();
return; return;
} }
self.addExpectationResult(false, { self.addExpectationResult(false, {
matcherName: "", matcherName: "",
passed: false, passed: false,
expected: "", expected: "",
actual: "", actual: "",
error: e error: e
}); });
} }
function complete() { function complete() {
@@ -340,7 +341,7 @@ getJasmineRequireObj().Spec = function(j$) {
return 'disabled'; return 'disabled';
} }
if (this.markedPending || !this.encounteredExpectations) { if (this.markedPending) {
return 'pending'; return 'pending';
} }
@@ -375,6 +376,8 @@ getJasmineRequireObj().Env = function(j$) {
var self = this; var self = this;
var global = options.global || j$.getGlobal(); var global = options.global || j$.getGlobal();
var totalSpecsDefined = 0;
var catchExceptions = true; var catchExceptions = true;
var realSetTimeout = j$.getGlobal().setTimeout; var realSetTimeout = j$.getGlobal().setTimeout;
@@ -385,9 +388,10 @@ getJasmineRequireObj().Env = function(j$) {
var spies = []; var spies = [];
this.currentSpec = null; var currentSpec = null;
var currentSuite = null;
this.reporter = new j$.ReportDispatcher([ var reporter = new j$.ReportDispatcher([
"jasmineStarted", "jasmineStarted",
"jasmineDone", "jasmineDone",
"suiteStarted", "suiteStarted",
@@ -396,14 +400,11 @@ getJasmineRequireObj().Env = function(j$) {
"specDone" "specDone"
]); ]);
this.lastUpdate = 0;
this.specFilter = function() { this.specFilter = function() {
return true; return true;
}; };
this.nextSpecId_ = 0; var equalityTesters = [];
this.nextSuiteId_ = 0;
this.equalityTesters_ = [];
var customEqualityTesters = []; var customEqualityTesters = [];
this.addCustomEqualityTester = function(tester) { this.addCustomEqualityTester = function(tester) {
@@ -412,6 +413,16 @@ getJasmineRequireObj().Env = function(j$) {
j$.Expectation.addCoreMatchers(j$.matchers); j$.Expectation.addCoreMatchers(j$.matchers);
var nextSpecId = 0;
var getNextSpecId = function() {
return 'spec' + nextSpecId++;
};
var nextSuiteId = 0;
var getNextSuiteId = function() {
return 'suite' + nextSuiteId++;
};
var expectationFactory = function(actual, spec) { var expectationFactory = function(actual, spec) {
return j$.Expectation.Factory({ return j$.Expectation.Factory({
util: j$.matchersUtil, util: j$.matchersUtil,
@@ -426,32 +437,34 @@ getJasmineRequireObj().Env = function(j$) {
}; };
var specStarted = function(spec) { var specStarted = function(spec) {
self.currentSpec = spec; currentSpec = spec;
self.reporter.specStarted(spec.result); reporter.specStarted(spec.result);
}; };
var beforeFns = function(currentSuite) { var beforeFns = function(suite) {
return function() { return function() {
var befores = []; var befores = [];
for (var suite = currentSuite; suite; suite = suite.parentSuite) { while(suite) {
befores = befores.concat(suite.beforeFns); befores = befores.concat(suite.beforeFns);
suite = suite.parentSuite;
} }
return befores.reverse(); return befores.reverse();
}; };
}; };
var afterFns = function(currentSuite) { var afterFns = function(suite) {
return function() { return function() {
var afters = []; var afters = [];
for (var suite = currentSuite; suite; suite = suite.parentSuite) { while(suite) {
afters = afters.concat(suite.afterFns); afters = afters.concat(suite.afterFns);
suite = suite.parentSuite;
} }
return afters; return afters;
}; };
}; };
var getSpecName = function(spec, currentSuite) { var getSpecName = function(spec, suite) {
return currentSuite.getFullName() + ' ' + spec.description; return suite.getFullName() + ' ' + spec.description;
}; };
// TODO: we may just be able to pass in the fn instead of wrapping here // TODO: we may just be able to pass in the fn instead of wrapping here
@@ -474,10 +487,6 @@ getJasmineRequireObj().Env = function(j$) {
return catchExceptions; return catchExceptions;
}; };
this.catchException = function(e) {
return j$.Spec.isPendingSpecException(e) || catchExceptions;
};
var maximumSpecCallbackDepth = 20; var maximumSpecCallbackDepth = 20;
var currentSpecCallbackDepth = 0; var currentSpecCallbackDepth = 0;
@@ -491,19 +500,136 @@ getJasmineRequireObj().Env = function(j$) {
} }
} }
var catchException = function(e) {
return j$.Spec.isPendingSpecException(e) || catchExceptions;
};
var queueRunnerFactory = function(options) { var queueRunnerFactory = function(options) {
options.catchException = self.catchException; options.catchException = catchException;
options.clearStack = options.clearStack || clearStack; options.clearStack = options.clearStack || clearStack;
new j$.QueueRunner(options).execute(); new j$.QueueRunner(options).execute();
}; };
var totalSpecsDefined = 0; var topSuite = new j$.Suite({
this.specFactory = function(description, fn, suite) { env: this,
id: getNextSuiteId(),
description: 'Jasmine__TopLevel__Suite',
queueRunner: queueRunnerFactory,
resultCallback: function() {} // TODO - hook this up
});
runnableLookupTable[topSuite.id] = topSuite;
currentSuite = topSuite;
this.topSuite = function() {
return topSuite;
};
this.execute = function(runnablesToRun) {
runnablesToRun = runnablesToRun || [topSuite.id];
var allFns = [];
for(var i = 0; i < runnablesToRun.length; i++) {
var runnable = runnableLookupTable[runnablesToRun[i]];
allFns.push((function(runnable) { return function(done) { runnable.execute(done); }; })(runnable));
}
reporter.jasmineStarted({
totalSpecsDefined: totalSpecsDefined
});
queueRunnerFactory({fns: allFns, onComplete: reporter.jasmineDone});
};
this.addReporter = function(reporterToAdd) {
reporter.addReporter(reporterToAdd);
};
this.addMatchers = function(matchersToAdd) {
j$.Expectation.addMatchers(matchersToAdd);
};
this.spyOn = function(obj, methodName) {
if (j$.util.isUndefined(obj)) {
throw new Error("spyOn could not find an object to spy upon for " + methodName + "()");
}
if (j$.util.isUndefined(obj[methodName])) {
throw new Error(methodName + '() method does not exist');
}
if (obj[methodName] && j$.isSpy(obj[methodName])) {
//TODO?: should this return the current spy? Downside: may cause user confusion about spy state
throw new Error(methodName + ' has already been spied upon');
}
var spy = j$.createSpy(methodName, obj[methodName]);
spies.push({
spy: spy,
baseObj: obj,
methodName: methodName,
originalValue: obj[methodName]
});
obj[methodName] = spy;
return spy;
};
var suiteFactory = function(description) {
var suite = new j$.Suite({
env: self,
id: getNextSuiteId(),
description: description,
parentSuite: currentSuite,
queueRunner: queueRunnerFactory,
onStart: suiteStarted,
resultCallback: function(attrs) {
reporter.suiteDone(attrs);
}
});
runnableLookupTable[suite.id] = suite;
return suite;
};
this.describe = function(description, specDefinitions) {
var suite = suiteFactory(description);
var parentSuite = currentSuite;
parentSuite.addChild(suite);
currentSuite = suite;
var declarationError = null;
try {
specDefinitions.call(suite);
} catch (e) {
declarationError = e;
}
if (declarationError) {
this.it("encountered a declaration exception", function() {
throw declarationError;
});
}
currentSuite = parentSuite;
return suite;
};
this.xdescribe = function(description, specDefinitions) {
var suite = this.describe(description, specDefinitions);
suite.disable();
return suite;
};
var specFactory = function(description, fn, suite) {
totalSpecsDefined++; totalSpecsDefined++;
var spec = new j$.Spec({ var spec = new j$.Spec({
id: self.nextSpecId(), id: getNextSpecId(),
beforeFns: beforeFns(suite), beforeFns: beforeFns(suite),
afterFns: afterFns(suite), afterFns: afterFns(suite),
expectationFactory: expectationFactory, expectationFactory: expectationFactory,
@@ -539,193 +665,45 @@ getJasmineRequireObj().Env = function(j$) {
function specResultCallback(result) { function specResultCallback(result) {
removeAllSpies(); removeAllSpies();
j$.Expectation.resetMatchers(); j$.Expectation.resetMatchers();
customEqualityTesters.length = 0; customEqualityTesters = [];
self.clock.uninstall(); currentSpec = null;
self.currentSpec = null; reporter.specDone(result);
self.reporter.specDone(result);
} }
}; };
var suiteStarted = function(suite) { var suiteStarted = function(suite) {
self.reporter.suiteStarted(suite.result); reporter.suiteStarted(suite.result);
}; };
var suiteConstructor = j$.Suite; this.it = function(description, fn) {
var spec = specFactory(description, fn, currentSuite);
this.topSuite = new j$.Suite({ currentSuite.addChild(spec);
env: this, return spec;
id: this.nextSuiteId(),
description: 'Jasmine__TopLevel__Suite',
queueRunner: queueRunnerFactory,
completeCallback: function() {}, // TODO - hook this up
resultCallback: function() {} // TODO - hook this up
});
runnableLookupTable[this.topSuite.id] = this.topSuite;
this.currentSuite = this.topSuite;
this.suiteFactory = function(description) {
var suite = new suiteConstructor({
env: self,
id: self.nextSuiteId(),
description: description,
parentSuite: self.currentSuite,
queueRunner: queueRunnerFactory,
onStart: suiteStarted,
resultCallback: function(attrs) {
self.reporter.suiteDone(attrs);
}
});
runnableLookupTable[suite.id] = suite;
return suite;
}; };
this.execute = function(runnablesToRun) { this.xit = function(description, fn) {
runnablesToRun = runnablesToRun || [this.topSuite.id]; var spec = this.it(description, fn);
spec.pend();
var allFns = []; return spec;
for(var i = 0; i < runnablesToRun.length; i++) {
var runnable = runnableLookupTable[runnablesToRun[i]];
allFns.push((function(runnable) { return function(done) { runnable.execute(done); }; })(runnable));
}
this.reporter.jasmineStarted({
totalSpecsDefined: totalSpecsDefined
});
queueRunnerFactory({fns: allFns, onComplete: this.reporter.jasmineDone});
}; };
this.spyOn = function(obj, methodName) { this.expect = function(actual) {
if (j$.util.isUndefined(obj)) { return currentSpec.expect(actual);
throw new Error("spyOn could not find an object to spy upon for " + methodName + "()"); };
}
if (j$.util.isUndefined(obj[methodName])) { this.beforeEach = function(beforeEachFunction) {
throw new Error(methodName + '() method does not exist'); currentSuite.beforeEach(beforeEachFunction);
} };
if (obj[methodName] && j$.isSpy(obj[methodName])) { this.afterEach = function(afterEachFunction) {
//TODO?: should this return the current spy? Downside: may cause user confusion about spy state currentSuite.afterEach(afterEachFunction);
throw new Error(methodName + ' has already been spied upon'); };
}
var spy = j$.createSpy(methodName, obj[methodName]); this.pending = function() {
throw j$.Spec.pendingSpecExceptionMessage;
spies.push({
spy: spy,
baseObj: obj,
methodName: methodName,
originalValue: obj[methodName]
});
obj[methodName] = spy;
return spy;
}; };
} }
Env.prototype.addMatchers = function(matchersToAdd) {
j$.Expectation.addMatchers(matchersToAdd);
};
Env.prototype.version = function() {
return j$.version;
};
Env.prototype.expect = function(actual) {
return this.currentSpec.expect(actual);
};
// TODO: move this to closure
Env.prototype.versionString = function() {
console.log("DEPRECATED == use j$.version");
return j$.version;
};
// TODO: move this to closure
Env.prototype.nextSpecId = function() {
return 'spec' + this.nextSpecId_++;
};
// TODO: move this to closure
Env.prototype.nextSuiteId = function() {
return 'suite' + this.nextSuiteId_++;
};
// TODO: move this to closure
Env.prototype.addReporter = function(reporter) {
this.reporter.addReporter(reporter);
};
// TODO: move this to closure
Env.prototype.describe = function(description, specDefinitions) {
var suite = this.suiteFactory(description);
var parentSuite = this.currentSuite;
parentSuite.addSuite(suite);
this.currentSuite = suite;
var declarationError = null;
try {
specDefinitions.call(suite);
} catch (e) {
declarationError = e;
}
if (declarationError) {
this.it("encountered a declaration exception", function() {
throw declarationError;
});
}
this.currentSuite = parentSuite;
return suite;
};
// TODO: move this to closure
Env.prototype.xdescribe = function(description, specDefinitions) {
var suite = this.describe(description, specDefinitions);
suite.disable();
return suite;
};
// TODO: move this to closure
Env.prototype.it = function(description, fn) {
var spec = this.specFactory(description, fn, this.currentSuite);
this.currentSuite.addSpec(spec);
return spec;
};
// TODO: move this to closure
Env.prototype.xit = function(description, fn) {
var spec = this.it(description, fn);
spec.pend();
return spec;
};
// TODO: move this to closure
Env.prototype.beforeEach = function(beforeEachFunction) {
this.currentSuite.beforeEach(beforeEachFunction);
};
// TODO: move this to closure
Env.prototype.afterEach = function(afterEachFunction) {
this.currentSuite.afterEach(afterEachFunction);
};
// TODO: move this to closure
Env.prototype.pending = function() {
throw j$.Spec.pendingSpecExceptionMessage;
};
// TODO: Still needed?
Env.prototype.currentRunner = function() {
return this.topSuite;
};
return Env; return Env;
}; };
@@ -839,6 +817,7 @@ getJasmineRequireObj().Any = function() {
return Any; return Any;
}; };
getJasmineRequireObj().CallTracker = function() { getJasmineRequireObj().CallTracker = function() {
function CallTracker() { function CallTracker() {
@@ -905,7 +884,8 @@ getJasmineRequireObj().Clock = function() {
setInterval: setInterval, setInterval: setInterval,
clearInterval: clearInterval clearInterval: clearInterval
}, },
installed = false; installed = false,
timer;
self.install = function() { self.install = function() {
replace(global, fakeTimingFunctions); replace(global, fakeTimingFunctions);
@@ -960,8 +940,6 @@ getJasmineRequireObj().Clock = function() {
function legacyIE() { function legacyIE() {
//if these methods are polyfilled, apply will be present //if these methods are polyfilled, apply will be present
//TODO: it may be difficult to load the polyfill before jasmine loads
//(env should be new-ed inside of onload)
return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply; return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply;
} }
@@ -1163,12 +1141,21 @@ getJasmineRequireObj().Expectation = function() {
args.unshift(this.actual); args.unshift(this.actual);
var result = matcherFactory(this.util, this.customEqualityTesters).compare.apply(null, args); var matcher = matcherFactory(this.util, this.customEqualityTesters),
matcherCompare = matcher.compare;
function defaultNegativeCompare() {
var result = matcher.compare.apply(null, args);
result.pass = !result.pass;
return result;
}
if (this.isNot) { if (this.isNot) {
result.pass = !result.pass; matcherCompare = matcher.negativeCompare || defaultNegativeCompare;
} }
var result = matcherCompare.apply(null, args);
if (!result.pass) { if (!result.pass) {
if (!result.message) { if (!result.message) {
args.unshift(this.isNot); args.unshift(this.isNot);
@@ -1364,8 +1351,8 @@ getJasmineRequireObj().pp = function(j$) {
PrettyPrinter.prototype.iterateObject = function(obj, fn) { PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) { for (var property in obj) {
if (!obj.hasOwnProperty(property)) continue; if (!obj.hasOwnProperty(property)) { continue; }
if (property == '__Jasmine_been_here_before__') continue; if (property == '__Jasmine_been_here_before__') { continue; }
fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) && fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
obj.__lookupGetter__(property) !== null) : false); obj.__lookupGetter__(property) !== null) : false);
} }
@@ -1522,11 +1509,11 @@ getJasmineRequireObj().ReportDispatcher = function() {
for (var i = 0; i < dispatchedMethods.length; i++) { for (var i = 0; i < dispatchedMethods.length; i++) {
var method = dispatchedMethods[i]; var method = dispatchedMethods[i];
this[method] = function(m) { this[method] = (function(m) {
return function() { return function() {
dispatch(m, arguments); dispatch(m, arguments);
}; };
}(method); }(method));
} }
var reporters = []; var reporters = [];
@@ -1610,7 +1597,6 @@ getJasmineRequireObj().Suite = function() {
this.parentSuite = attrs.parentSuite; this.parentSuite = attrs.parentSuite;
this.description = attrs.description; this.description = attrs.description;
this.onStart = attrs.onStart || function() {}; this.onStart = attrs.onStart || function() {};
this.completeCallback = attrs.completeCallback || function() {}; // TODO: this is unused
this.resultCallback = attrs.resultCallback || function() {}; this.resultCallback = attrs.resultCallback || function() {};
this.clearStack = attrs.clearStack || function(fn) {fn();}; this.clearStack = attrs.clearStack || function(fn) {fn();};
@@ -1619,9 +1605,7 @@ getJasmineRequireObj().Suite = function() {
this.queueRunner = attrs.queueRunner || function() {}; this.queueRunner = attrs.queueRunner || function() {};
this.disabled = false; this.disabled = false;
this.children_ = []; // TODO: rename this.children = [];
this.suites = []; // TODO: needed?
this.specs = []; // TODO: needed?
this.result = { this.result = {
id: this.id, id: this.id,
@@ -1653,19 +1637,8 @@ getJasmineRequireObj().Suite = function() {
this.afterFns.unshift(fn); this.afterFns.unshift(fn);
}; };
Suite.prototype.addSpec = function(spec) { Suite.prototype.addChild = function(child) {
this.children_.push(spec); this.children.push(child);
this.specs.push(spec); // TODO: needed?
};
Suite.prototype.addSuite = function(suite) {
suite.parentSuite = this;
this.children_.push(suite);
this.suites.push(suite); // TODO: needed?
};
Suite.prototype.children = function() {
return this.children_;
}; };
Suite.prototype.execute = function(onComplete) { Suite.prototype.execute = function(onComplete) {
@@ -1675,11 +1648,10 @@ getJasmineRequireObj().Suite = function() {
return; return;
} }
var allFns = [], var allFns = [];
children = this.children_;
for (var i = 0; i < children.length; i++) { for (var i = 0; i < this.children.length; i++) {
allFns.push(wrapChildAsAsync(children[i])); allFns.push(wrapChildAsAsync(this.children[i]));
} }
this.onStart(this); this.onStart(this);
@@ -1701,7 +1673,7 @@ getJasmineRequireObj().Suite = function() {
return function(done) { child.execute(done); }; return function(done) { child.execute(done); };
} }
}; };
return Suite; return Suite;
}; };
@@ -1727,6 +1699,7 @@ getJasmineRequireObj().Timer = function() {
return Timer; return Timer;
}; };
getJasmineRequireObj().matchersUtil = function(j$) { getJasmineRequireObj().matchersUtil = function(j$) {
// TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter? // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
@@ -1766,7 +1739,9 @@ getJasmineRequireObj().matchersUtil = function(j$) {
if (expected.length > 0) { if (expected.length > 0) {
for (var i = 0; i < expected.length; i++) { for (var i = 0; i < expected.length; i++) {
if (i > 0) message += ","; if (i > 0) {
message += ",";
}
message += " " + j$.pp(expected[i]); message += " " + j$.pp(expected[i]);
} }
} }
@@ -1814,11 +1789,11 @@ getJasmineRequireObj().matchersUtil = function(j$) {
// Identical objects are equal. `0 === -0`, but they aren't identical. // Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if (a === b) return a !== 0 || 1 / a == 1 / b; if (a === b) { return a !== 0 || 1 / a == 1 / b; }
// A strict comparison is necessary because `null == undefined`. // A strict comparison is necessary because `null == undefined`.
if (a === null || b === null) return a === b; if (a === null || b === null) { return a === b; }
var className = Object.prototype.toString.call(a); var className = Object.prototype.toString.call(a);
if (className != Object.prototype.toString.call(b)) return false; if (className != Object.prototype.toString.call(b)) { return false; }
switch (className) { switch (className) {
// Strings, numbers, dates, and booleans are compared by value. // Strings, numbers, dates, and booleans are compared by value.
case '[object String]': case '[object String]':
@@ -1842,14 +1817,14 @@ getJasmineRequireObj().matchersUtil = function(j$) {
a.multiline == b.multiline && a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase; a.ignoreCase == b.ignoreCase;
} }
if (typeof a != 'object' || typeof b != 'object') return false; if (typeof a != 'object' || typeof b != 'object') { return false; }
// Assume equality for cyclic structures. The algorithm for detecting cyclic // Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
var length = aStack.length; var length = aStack.length;
while (length--) { while (length--) {
// Linear search. Performance is inversely proportional to the number of // Linear search. Performance is inversely proportional to the number of
// unique nested structures. // unique nested structures.
if (aStack[length] == a) return bStack[length] == b; if (aStack[length] == a) { return bStack[length] == b; }
} }
// Add the first object to the stack of traversed objects. // Add the first object to the stack of traversed objects.
aStack.push(a); aStack.push(a);
@@ -1863,7 +1838,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
if (result) { if (result) {
// Deep compare the contents, ignoring non-numeric properties. // Deep compare the contents, ignoring non-numeric properties.
while (size--) { while (size--) {
if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) break; if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) { break; }
} }
} }
} else { } else {
@@ -1880,13 +1855,13 @@ getJasmineRequireObj().matchersUtil = function(j$) {
// Count the expected number of properties. // Count the expected number of properties.
size++; size++;
// Deep compare each member. // Deep compare each member.
if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) break; if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; }
} }
} }
// Ensure that both objects contain the same number of properties. // Ensure that both objects contain the same number of properties.
if (result) { if (result) {
for (key in b) { for (key in b) {
if (has(b, key) && !(size--)) break; if (has(b, key) && !(size--)) { break; }
} }
result = !size; result = !size;
} }
@@ -2388,5 +2363,5 @@ getJasmineRequireObj().toThrowError = function(j$) {
}; };
getJasmineRequireObj().version = function() { getJasmineRequireObj().version = function() {
return "2.0.0-rc3"; return "2.0.0-rc5";
}; };

View File

@@ -4,6 +4,6 @@
# #
module Jasmine module Jasmine
module Core module Core
VERSION = "2.0.0.rc3" VERSION = "2.0.0.rc5"
end end
end end

View File

@@ -1,7 +1,7 @@
{ {
"name": "jasmine-core", "name": "jasmine-core",
"license": "MIT", "license": "MIT",
"version": "2.0.0-rc3", "version": "2.0.0-rc5",
"devDependencies": { "devDependencies": {
"grunt": "~0.4.1", "grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.7.0", "grunt-contrib-jshint": "~0.7.0",