Code coverage report for debug\debuggability.js

Statements: 98.72% (77 / 78)      Branches: 82.05% (32 / 39)      Functions: 100% (21 / 21)      Lines: 98.7% (76 / 77)      Ignored: none     

All files » debug\ » debuggability.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152  8 8 8 8 8 8 8 8               8 2910 2910     8 14       8 2910 95 95 95         8 95     8 14     8 2944     8 2910   2910   2910     8 2944   2944 2944 14 14       8 12171   12171     8 4358   4358   4358 4358     8 93101   93101     8 4576   4576         8 27182   27182   27182 20741   27182     8 4495 3609 3609 2939   3609 2799   810         8 280     8 21     8 2         2     8 16     8 1 1     8 63816          
(function () { "use strict";
module.exports = function(Promise, CapturedTrace) {
var async = require("./async.js");
var util = require("./util.js");
var ASSERT = require("./assert.js");
var canAttachTrace = util.canAttachTrace;
var unhandledRejectionHandled;
var possiblyUnhandledRejection;
var debugging = true || !!(
    typeof process !== "undefined" &&
    typeof process.execPath === "string" &&
    typeof process.env === "object" &&
    (process.env["BLUEBIRD_DEBUG"] ||
        process.env["NODE_ENV"] === "development")
);
 
Promise.prototype._ensurePossibleRejectionHandled = function () {
    this._setRejectionIsUnhandled();
    async.invokeLater(this._notifyUnhandledRejection, this, undefined);
};
 
Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
    CapturedTrace.fireRejectionEvent("rejectionHandled",
                                  unhandledRejectionHandled, undefined, this);
};
 
Promise.prototype._notifyUnhandledRejection = function () {
    if (this._isRejectionUnhandled()) {
        var reason = this._getCarriedStackTrace() || this._settledValue;
        this._setUnhandledRejectionIsNotified();
        CapturedTrace.fireRejectionEvent("unhandledRejection",
                                      possiblyUnhandledRejection, reason, this);
    }
};
 
Promise.prototype._setUnhandledRejectionIsNotified = function () {
    this._bitField = this._bitField | 524288;
};
 
Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
    this._bitField = this._bitField & (~524288);
};
 
Promise.prototype._isUnhandledRejectionNotified = function () {
    return (this._bitField & 524288) > 0;
};
 
Promise.prototype._setRejectionIsUnhandled = function () {
    ASSERT((! this._isFollowing()),
    "!this._isFollowing()");
    ASSERT(this._isRejected(),
    "this._isRejected()");
    this._bitField = this._bitField | 2097152;
};
 
Promise.prototype._unsetRejectionIsUnhandled = function () {
    ASSERT((! this._isFollowing()),
    "!this._isFollowing()");
    this._bitField = this._bitField & (~2097152);
    if (this._isUnhandledRejectionNotified()) {
        this._unsetUnhandledRejectionIsNotified();
        this._notifyUnhandledRejectionIsHandled();
    }
};
 
Promise.prototype._isRejectionUnhandled = function () {
    ASSERT((! this._isFollowing()),
    "!this._isFollowing()");
    return (this._bitField & 2097152) > 0;
};
 
Promise.prototype._setCarriedStackTrace = function (capturedTrace) {
    ASSERT((! this._isFollowing()),
    "!this._isFollowing()");
    ASSERT(this._isRejected(),
    "this._isRejected()");
    this._bitField = this._bitField | 1048576;
    this._fulfillmentHandler0 = capturedTrace;
};
 
Promise.prototype._isCarryingStackTrace = function () {
    ASSERT((! this._isFollowing()),
    "!this._isFollowing()");
    return (this._bitField & 1048576) > 0;
};
 
Promise.prototype._getCarriedStackTrace = function () {
    ASSERT(this._isRejected(),
    "this._isRejected()");
    return this._isCarryingStackTrace()
        ? this._fulfillmentHandler0
        : undefined;
};
 
Promise.prototype._captureStackTrace = function () {
    ASSERT((arguments.length === 0),
    "arguments.length === 0");
    ASSERT((this._trace == null),
    "this._trace == null");
    if (debugging) {
        this._trace = new CapturedTrace(this._peekContext());
    }
    return this;
};
 
Promise.prototype._attachExtraTrace = function (error, ignoreSelf) {
    if (debugging && canAttachTrace(error)) {
        var trace = this._trace;
        if (trace !== undefined) {
            if (ignoreSelf) trace = trace._parent;
        }
        if (trace !== undefined) {
            trace.attachExtraTrace(error);
        } else {
            CapturedTrace.cleanHeaderStack(error, true);
        }
    }
};
 
Promise.onPossiblyUnhandledRejection = function (fn) {
    possiblyUnhandledRejection = typeof fn === "function" ? fn : undefined;
};
 
Promise.onUnhandledRejectionHandled = function (fn) {
    unhandledRejectionHandled = typeof fn === "function" ? fn : undefined;
};
 
Promise.longStackTraces = function () {
    Iif (async.haveItemsQueued() &&
        debugging === false
   ) {
        throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a    See http://goo.gl/DT1qyG\u000a");
    }
    debugging = CapturedTrace.isSupported();
};
 
Promise.hasLongStackTraces = function () {
    return debugging && CapturedTrace.isSupported();
};
 
if (!CapturedTrace.isSupported()) {
    Promise.longStackTraces = function(){};
    debugging = false;
}
 
return function() {
    return debugging;
};
};
 
}());