Merge in Pivotal changes

This commit is contained in:
ragaskar
2009-07-29 22:41:38 -07:00
14 changed files with 538 additions and 242 deletions

View File

@@ -18,6 +18,7 @@ jasmine.Env = function() {
};
this.nextSpecId_ = 0;
this.nextSuiteId_ = 0;
this.equalityTesters_ = [];
};

58
src/JsApiReporter.js Normal file
View File

@@ -0,0 +1,58 @@
/** JavaScript API reporter.
*
* @constructor
*/
jasmine.JsApiReporter = function() {
this.started = false;
this.finished = false;
this.suites = [];
this.results = {};
};
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
this.started = true;
for (var i = 0; i < runner.suites.length; i++) {
var suite = runner.suites[i];
this.suites.push(this.summarize_(suite));
}
};
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
var summary = {
id: suiteOrSpec.id,
name: suiteOrSpec.description,
type: suiteOrSpec instanceof jasmine.Suite ? 'suite' : 'spec',
children: []
};
if (suiteOrSpec.specs) {
for (var i = 0; i < suiteOrSpec.specs.length; i++) {
summary.children.push(this.summarize_(suiteOrSpec.specs[i]));
}
}
return summary;
};
//noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
this.finished = true;
};
//noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
};
//noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
this.results[spec.id] = {
messages: spec.results.getItems(),
result: spec.results.failedCount > 0 ? "failed" : "passed"
};
};
//noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.log = function(str) {
};

View File

@@ -75,6 +75,6 @@ jasmine.NestedResults.prototype.addResult = function(result) {
/**
* @returns {Boolean} True if <b>everything</b> below passed
*/
jasmine.NestedResults.prototype.passed = function() {
jasmine.NestedResults.prototype.__defineGetter__('passed', function() {
return this.passedCount === this.totalCount;
};
});

View File

@@ -28,7 +28,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
} else if (value instanceof jasmine.Matchers.Any) {
this.emitScalar(value.toString());
} else if (typeof value === 'string') {
this.emitScalar("'" + value + "'");
this.emitString(value);
} else if (typeof value === 'function') {
this.emitScalar('Function');
} else if (typeof value.nodeType === 'number') {
@@ -63,6 +63,7 @@ jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
jasmine.StringPrettyPrinter = function() {
jasmine.PrettyPrinter.call(this);
@@ -75,6 +76,10 @@ jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
this.append(value);
};
jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
this.append("'" + value + "'");
};
jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
this.append('[ ');
for (var i = 0; i < array.length; i++) {

View File

@@ -22,6 +22,6 @@ jasmine.Reporter.prototype.reportSpecResults = function(spec) {
};
//noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.log = function (str) {
jasmine.Reporter.prototype.log = function(str) {
};

View File

@@ -9,7 +9,8 @@
*/
jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
jasmine.ActionCollection.call(this, env);
this.id = env.nextSuiteId_++;
this.description = description;
this.specs = this.actions;
this.parentSuite = parentSuite;
@@ -43,6 +44,9 @@ jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
jasmine.Suite.prototype.getResults = function() {
var results = new jasmine.NestedResults();
results.description = this.description;
results.id = this.id;
for (var i = 0; i < this.specs.length; i++) {
results.rollupCounts(this.specs[i].getResults());
}