Rebuild jasmine.js

This commit is contained in:
ragaskar 2009-08-19 08:50:56 -07:00
parent 2a4241323d
commit bc790d6b87
1 changed files with 26 additions and 36 deletions

View File

@ -40,12 +40,16 @@ jasmine.MessageResult = function(text) {
jasmine.ExpectationResult = function(passed, message, details) {
this.type = 'ExpectationResult';
this.passed = passed;
this.passed_ = passed;
this.message = message;
this.details = details;
this.trace = new Error(message); // todo: test better
};
jasmine.ExpectationResult.prototype.passed = function () {
return this.passed_;
};
/**
* Getter for the Jasmine environment. Ensures one gets created
*/
@ -1240,7 +1244,7 @@ jasmine.NestedResults.prototype.addResult = function(result) {
this.rollupCounts(result);
} else {
this.totalCount++;
if (result.passed) {
if (result.passed()) {
this.passedCount++;
} else {
this.failedCount++;
@ -1437,9 +1441,11 @@ jasmine.Queue.prototype.finish = function () {
};
jasmine.Queue.prototype.getResults = function () {
var results = [];
var results = new jasmine.NestedResults();
for (var i = 0; i < this.blocks.length; i++) {
results.push(this.blocks[i].getResults());
if (this.blocks[i].getResults) {
results.addResult(this.blocks[i].getResults());
}
}
return results;
};
@ -1488,6 +1494,7 @@ jasmine.Runner = function(env) {
var self = this;
self.env = env;
self.queue = new jasmine.Queue(env);
self.suites = [];
};
jasmine.Runner.prototype.execute = function() {
@ -1495,51 +1502,33 @@ jasmine.Runner.prototype.execute = function() {
if (self.env.reporter.reportRunnerStarting) {
self.env.reporter.reportRunnerStarting(this);
}
self.queue.start(function () { self.finishCallback(); });
self.queue.start(function () {
self.finishCallback();
});
};
jasmine.Runner.prototype.finishCallback = function() {
this.env.reporter.reportRunnerResults(this);
};
jasmine.Runner.prototype.addSuite = function(suite) {
this.suites.push(suite);
};
jasmine.Runner.prototype.add = function(block) {
if (block instanceof jasmine.Suite) {
this.addSuite(block);
}
this.queue.add(block);
};
jasmine.Runner.prototype.getAllSuites = function() {
var suitesToReturn = [];
function addSuite(suite) {
suitesToReturn.push(suite);
for (var j = 0; j < suite.specs.length; j++) {
var spec = suite.specs[j];
if (spec instanceof jasmine.Suite) {
addSuite(spec);
}
}
}
for (var i = 0; i < this.suites.length; i++) {
var suite = this.suites[i];
addSuite(suite);
}
return suitesToReturn;
return this.suites;
};
jasmine.Runner.prototype.getResults = function() {
var results = new jasmine.NestedResults();
var runnerResults = this.queue.getResults();
for (var i=0; i < runnerResults.length; i++) {
var suiteResults = runnerResults[i];
for (var j=0; j < suiteResults.length; j++) {
results.rollupCounts(suiteResults[j]);
}
}
return results;
return this.queue.getResults();
};
/**
* Internal representation of a Jasmine specification, or test.
@ -1557,7 +1546,6 @@ jasmine.Spec = function(env, suite, description) {
spec.description = description;
spec.queue = new jasmine.Queue(env);
spec.finished = false;
spec.afterCallbacks = [];
spec.spies_ = [];
@ -1660,8 +1648,7 @@ jasmine.Spec.prototype.execute = function(onComplete) {
var spec = this;
if (!spec.env.specFilter(spec)) {
spec.results.skipped = true;
spec.finishCallback();
spec.finished = true;
spec.finish(onComplete);
return;
}
@ -1783,6 +1770,9 @@ jasmine.Suite.prototype.getResults = function() {
};
jasmine.Suite.prototype.add = function(block) {
if (block instanceof jasmine.Suite) {
this.env.currentRunner.addSuite(block);
}
this.queue.add(block);
};