1 /**
  2  * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
  3  *
  4  * @constructor
  5  */
  6 jasmine.NestedResults = function() {
  7   /**
  8    * The total count of results
  9    */
 10   this.totalCount = 0;
 11   /**
 12    * Number of passed results
 13    */
 14   this.passedCount = 0;
 15   /**
 16    * Number of failed results
 17    */
 18   this.failedCount = 0;
 19   /**
 20    * Was this suite/spec skipped?
 21    */
 22   this.skipped = false;
 23   /**
 24    * @ignore
 25    */
 26   this.items_ = [];
 27 };
 28 
 29 /**
 30  * Roll up the result counts.
 31  *
 32  * @param result
 33  */
 34 jasmine.NestedResults.prototype.rollupCounts = function(result) {
 35   this.totalCount += result.totalCount;
 36   this.passedCount += result.passedCount;
 37   this.failedCount += result.failedCount;
 38 };
 39 
 40 /**
 41  * Adds a log message.
 42  * @param values Array of message parts which will be concatenated later.
 43  */
 44 jasmine.NestedResults.prototype.log = function(values) {
 45   this.items_.push(new jasmine.MessageResult(values));
 46 };
 47 
 48 /**
 49  * Getter for the results: message & results.
 50  */
 51 jasmine.NestedResults.prototype.getItems = function() {
 52   return this.items_;
 53 };
 54 
 55 /**
 56  * Adds a result, tracking counts (total, passed, & failed)
 57  * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
 58  */
 59 jasmine.NestedResults.prototype.addResult = function(result) {
 60   if (result.type != 'log') {
 61     if (result.items_) {
 62       this.rollupCounts(result);
 63     } else {
 64       this.totalCount++;
 65       if (result.passed()) {
 66         this.passedCount++;
 67       } else {
 68         this.failedCount++;
 69       }
 70     }
 71   }
 72   this.items_.push(result);
 73 };
 74 
 75 /**
 76  * @returns {Boolean} True if <b>everything</b> below passed
 77  */
 78 jasmine.NestedResults.prototype.passed = function() {
 79   return this.passedCount === this.totalCount;
 80 };
 81