Skip to content

Commit

Permalink
refactor: rename keep_ssfi to lockSsfi
Browse files Browse the repository at this point in the history
  • Loading branch information
meeber committed Feb 12, 2017
1 parent 48ed351 commit 2999156
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 53 deletions.
8 changes: 4 additions & 4 deletions lib/chai/assertion.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function (_chai, util) {
* in environments that support `Error.captureStackTrace`, and only when
* `Chai.config.includeStack` hasn't been set to `false`.
*
* - `keep_ssfi`: This flag controls whether or not the given `ssfi` flag
* - `lockSsfi`: This flag controls whether or not the given `ssfi` flag
* should retain its current value, even as assertions are chained off of
* this object. This is usually set to `true` when creating a new assertion
* from within another assertion. It's also temporarily set to `true` before
Expand All @@ -55,13 +55,13 @@ module.exports = function (_chai, util) {
* @param {Mixed} obj target of the assertion
* @param {String} msg (optional) custom error message
* @param {Function} ssfi (optional) starting point for removing stack frames
* @param {Boolean} keep_ssfi (optional) whether or not ssfi should be frozen
* @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked
* @api private
*/

function Assertion (obj, msg, ssfi, keep_ssfi) {
function Assertion (obj, msg, ssfi, lockSsfi) {
flag(this, 'ssfi', ssfi || Assertion);
flag(this, 'keep_ssfi', keep_ssfi);
flag(this, 'lockSsfi', lockSsfi);
flag(this, 'object', obj);
flag(this, 'message', msg);

Expand Down
2 changes: 1 addition & 1 deletion lib/chai/core/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ module.exports = function (chai, _) {
props.forEach(function (prop) {
var propAssertion = new Assertion(obj);
_.transferFlags(this, propAssertion, true);
flag(propAssertion, 'keep_ssfi', true);
flag(propAssertion, 'lockSsfi', true);

if (!negate || props.length === 1) {
propAssertion.property(prop, val[prop]);
Expand Down
8 changes: 4 additions & 4 deletions lib/chai/utils/addChainableMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ module.exports = function addChainableMethod(ctx, name, method, chainingBehavior
// frames from the stack trace of a failed assertion.
//
// However, we only want to use this function as the starting point if
// the `keep_ssfi` flag isn't set.
// the `lockSsfi` flag isn't set.
//
// If the `keep_ssfi` flag is set, then this assertion is being
// If the `lockSsfi` flag is set, then this assertion is being
// invoked from inside of another assertion. In this case, the `ssfi`
// flag has already been set by the outer assertion.
//
// Note that overwriting a chainable method merely replaces the saved
// methods in `ctx.__methods` instead of completely replacing the
// overwritten assertion. Therefore, an overwriting assertion won't
// set the `ssfi` or `keep_ssfi` flags.
if (!flag(this, 'keep_ssfi')) {
// set the `ssfi` or `lockSsfi` flags.
if (!flag(this, 'lockSsfi')) {
flag(this, 'ssfi', chainableMethodWrapper);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/chai/utils/addMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ module.exports = function addMethod(ctx, name, method) {
// a failed assertion.
//
// However, we only want to use this function as the starting point if the
// `keep_ssfi` flag isn't set.
// `lockSsfi` flag isn't set.
//
// If the `keep_ssfi` flag is set, then either this assertion has been
// If the `lockSsfi` flag is set, then either this assertion has been
// overwritten by another assertion, or this assertion is being invoked from
// inside of another assertion. In the first case, the `ssfi` flag has
// already been set by the overwriting assertion. In the second case, the
// `ssfi` flag has already been set by the outer assertion.
if (!flag(this, 'keep_ssfi')) {
if (!flag(this, 'lockSsfi')) {
flag(this, 'ssfi', methodWrapper);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/chai/utils/addProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ module.exports = function addProperty(ctx, name, getter) {
// stack trace of a failed assertion.
//
// However, we only want to use this function as the starting point if
// the `keep_ssfi` flag isn't set and proxy protection is disabled.
// the `lockSsfi` flag isn't set and proxy protection is disabled.
//
// If the `keep_ssfi` flag is set, then either this assertion has been
// If the `lockSsfi` flag is set, then either this assertion has been
// overwritten by another assertion, or this assertion is being invoked
// from inside of another assertion. In the first case, the `ssfi` flag
// has already been set by the overwriting assertion. In the second
// case, the `ssfi` flag has already been set by the outer assertion.
//
// If proxy protection is enabled, then the `ssfi` flag has already been
// set by the proxy getter.
if (!isProxyEnabled() && !flag(this, 'keep_ssfi')) {
if (!isProxyEnabled() && !flag(this, 'lockSsfi')) {
flag(this, 'ssfi', propertyGetter);
}

Expand Down
14 changes: 7 additions & 7 deletions lib/chai/utils/overwriteMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@ module.exports = function overwriteMethod(ctx, name, method) {
// the stack trace of a failed assertion.
//
// However, we only want to use this function as the starting point if the
// `keep_ssfi` flag isn't set.
// `lockSsfi` flag isn't set.
//
// If the `keep_ssfi` flag is set, then either this assertion has been
// If the `lockSsfi` flag is set, then either this assertion has been
// overwritten by another assertion, or this assertion is being invoked from
// inside of another assertion. In the first case, the `ssfi` flag has
// already been set by the overwriting assertion. In the second case, the
// `ssfi` flag has already been set by the outer assertion.
if (!flag(this, 'keep_ssfi')) {
if (!flag(this, 'lockSsfi')) {
flag(this, 'ssfi', overwritingMethodWrapper);
}

// Setting the `keep_ssfi` flag to `true` prevents the overwritten assertion
// Setting the `lockSsfi` flag to `true` prevents the overwritten assertion
// from changing the `ssfi` flag. By this point, the `ssfi` flag is already
// set to the correct starting point for this assertion.
var origKeepSsfi = flag(this, 'keep_ssfi');
flag(this, 'keep_ssfi', true);
var origLockSsfi = flag(this, 'lockSsfi');
flag(this, 'lockSsfi', true);
var result = method(_super).apply(this, arguments);
flag(this, 'keep_ssfi', origKeepSsfi);
flag(this, 'lockSsfi', origLockSsfi);

if (result !== undefined) {
return result;
Expand Down
14 changes: 7 additions & 7 deletions lib/chai/utils/overwriteProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,27 @@ module.exports = function overwriteProperty(ctx, name, getter) {
// from the stack trace of a failed assertion.
//
// However, we only want to use this function as the starting point if
// the `keep_ssfi` flag isn't set and proxy protection is disabled.
// the `lockSsfi` flag isn't set and proxy protection is disabled.
//
// If the `keep_ssfi` flag is set, then either this assertion has been
// If the `lockSsfi` flag is set, then either this assertion has been
// overwritten by another assertion, or this assertion is being invoked
// from inside of another assertion. In the first case, the `ssfi` flag
// has already been set by the overwriting assertion. In the second
// case, the `ssfi` flag has already been set by the outer assertion.
//
// If proxy protection is enabled, then the `ssfi` flag has already been
// set by the proxy getter.
if (!isProxyEnabled() && !flag(this, 'keep_ssfi')) {
if (!isProxyEnabled() && !flag(this, 'lockSsfi')) {
flag(this, 'ssfi', overwritingPropertyGetter);
}

// Setting the `keep_ssfi` flag to `true` prevents the overwritten
// Setting the `lockSsfi` flag to `true` prevents the overwritten
// assertion from changing the `ssfi` flag. By this point, the `ssfi`
// flag is already set to the correct starting point for this assertion.
var origKeepSsfi = flag(this, 'keep_ssfi');
flag(this, 'keep_ssfi', true);
var origLockSsfi = flag(this, 'lockSsfi');
flag(this, 'lockSsfi', true);
var result = getter(_super).call(this);
flag(this, 'keep_ssfi', origKeepSsfi);
flag(this, 'lockSsfi', origLockSsfi);

if (result !== undefined) {
return result;
Expand Down
4 changes: 2 additions & 2 deletions lib/chai/utils/proxify.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ module.exports = function proxify(obj, nonChainableMethodName) {
// the stack once the method is invoked. Note that Chai builtin assertion
// properties such as `__flags` are skipped since this is only meant to
// capture the starting point of an assertion. This step is also skipped
// if the `keep_ssfi` flag is set, thus indicating that this assertion is
// if the `lockSsfi` flag is set, thus indicating that this assertion is
// being called from within another assertion. In that case, the `ssfi`
// flag is already set to the outer assertion's starting point.
if (builtins.indexOf(property) === -1 && !flag(target, 'keep_ssfi')) {
if (builtins.indexOf(property) === -1 && !flag(target, 'lockSsfi')) {
flag(target, 'ssfi', proxyGetter);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/chai/utils/transferFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* Transfer all the flags for `assertion` to `object`. If
* `includeAll` is set to `false`, then the base Chai
* assertion flags (namely `object`, `ssfi`, `keep_ssfi`,
* assertion flags (namely `object`, `ssfi`, `lockSsfi`,
* and `message`) will not be transferred.
*
*
Expand Down Expand Up @@ -38,7 +38,7 @@ module.exports = function transferFlags(assertion, object, includeAll) {

for (var flag in flags) {
if (includeAll ||
(flag !== 'object' && flag !== 'ssfi' && flag !== 'keep_ssfi' && flag != 'message')) {
(flag !== 'object' && flag !== 'ssfi' && flag !== 'lockSsfi' && flag != 'message')) {
object.__flags[flag] = flags[flag];
}
}
Expand Down
40 changes: 20 additions & 20 deletions test/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('utilities', function () {
expect(utils.flag(obj, 'object')).to.equal(undefined);
expect(utils.flag(obj, 'message')).to.equal(undefined);
expect(utils.flag(obj, 'ssfi')).to.equal(undefined);
expect(utils.flag(obj, 'keep_ssfi')).to.equal(undefined);
expect(utils.flag(obj, 'lockSsfi')).to.equal(undefined);
expect(utils.flag(obj, 'negate')).to.equal(true);
expect(utils.flag(obj, 'flagMe')).to.equal(flag);
});
Expand All @@ -73,7 +73,7 @@ describe('utilities', function () {
expect(utils.flag(obj, 'object')).to.equal(target);
expect(utils.flag(obj, 'message')).to.equal("message");
expect(utils.flag(obj, 'ssfi')).to.equal(test);
expect(utils.flag(obj, 'keep_ssfi')).to.equal(true);
expect(utils.flag(obj, 'lockSsfi')).to.equal(true);
expect(utils.flag(obj, 'negate')).to.equal(true);
expect(utils.flag(obj, 'flagMe')).to.equal(flag);
});
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('utilities', function () {
expect(anotherAssertion.length.constructor).to.equal(assertionConstructor);
});

it('addMethod sets `ssfi` when `keep_ssfi` isn\'t set', function () {
it('addMethod sets `ssfi` when `lockSsfi` isn\'t set', function () {
var origAssertion = expect(1);
var origSsfi = utils.flag(origAssertion, 'ssfi');

Expand All @@ -165,11 +165,11 @@ describe('utilities', function () {
expect(origSsfi).to.not.equal(newSsfi);
});

it('addMethod doesn\'t set `ssfi` when `keep_ssfi` is set', function () {
it('addMethod doesn\'t set `ssfi` when `lockSsfi` is set', function () {
var origAssertion = expect(1);
var origSsfi = utils.flag(origAssertion, 'ssfi');

utils.flag(origAssertion, 'keep_ssfi', true);
utils.flag(origAssertion, 'lockSsfi', true);

var newAssertion = origAssertion.eqqqual(1);
var newSsfi = utils.flag(newAssertion, 'ssfi');
Expand Down Expand Up @@ -340,7 +340,7 @@ describe('utilities', function () {
expect(expect('four').four()).to.be.an.instanceOf(assertionConstructor);
});

it('overwriteMethod sets `ssfi` when `keep_ssfi` isn\'t set', function () {
it('overwriteMethod sets `ssfi` when `lockSsfi` isn\'t set', function () {
var origAssertion = expect(4);
var origSsfi = utils.flag(origAssertion, 'ssfi');

Expand All @@ -350,11 +350,11 @@ describe('utilities', function () {
expect(origSsfi).to.not.equal(newSsfi);
});

it('overwriteMethod doesn\'t set `ssfi` when `keep_ssfi` is set', function () {
it('overwriteMethod doesn\'t set `ssfi` when `lockSsfi` is set', function () {
var origAssertion = expect(4);
var origSsfi = utils.flag(origAssertion, 'ssfi');

utils.flag(origAssertion, 'keep_ssfi', true);
utils.flag(origAssertion, 'lockSsfi', true);

var newAssertion = origAssertion.four();
var newSsfi = utils.flag(newAssertion, 'ssfi');
Expand Down Expand Up @@ -436,7 +436,7 @@ describe('utilities', function () {
expect(expect([1, 2, 3]).thing).to.be.an.instanceOf(assertionConstructor);
});

it('addProperty sets `ssfi` when `keep_ssfi` isn\'t set', function () {
it('addProperty sets `ssfi` when `lockSsfi` isn\'t set', function () {
var origAssertion = expect(1);
var origSsfi = utils.flag(origAssertion, 'ssfi');

Expand All @@ -446,11 +446,11 @@ describe('utilities', function () {
expect(origSsfi).to.not.equal(newSsfi);
});

it('addProperty doesn\'t set `ssfi` when `keep_ssfi` is set', function () {
it('addProperty doesn\'t set `ssfi` when `lockSsfi` is set', function () {
var origAssertion = expect(1);
var origSsfi = utils.flag(origAssertion, 'ssfi');

utils.flag(origAssertion, 'keep_ssfi', true);
utils.flag(origAssertion, 'lockSsfi', true);

var newAssertion = origAssertion.to.be.tea;
var newSsfi = utils.flag(newAssertion, 'ssfi');
Expand Down Expand Up @@ -596,7 +596,7 @@ describe('utilities', function () {
expect(expect([1, 2, 3]).foo).to.be.an.instanceOf(assertionConstructor);
});

it('overwriteProperty sets `ssfi` when `keep_ssfi` isn\'t set', function () {
it('overwriteProperty sets `ssfi` when `lockSsfi` isn\'t set', function () {
var origAssertion = expect(4);
var origSsfi = utils.flag(origAssertion, 'ssfi');

Expand All @@ -606,11 +606,11 @@ describe('utilities', function () {
expect(origSsfi).to.not.equal(newSsfi);
});

it('overwriteProperty doesn\'t set `ssfi` when `keep_ssfi` is set', function () {
it('overwriteProperty doesn\'t set `ssfi` when `lockSsfi` is set', function () {
var origAssertion = expect(4);
var origSsfi = utils.flag(origAssertion, 'ssfi');

utils.flag(origAssertion, 'keep_ssfi', true);
utils.flag(origAssertion, 'lockSsfi', true);

var newAssertion = origAssertion.to.be.four;
var newSsfi = utils.flag(newAssertion, 'ssfi');
Expand Down Expand Up @@ -902,7 +902,7 @@ describe('utilities', function () {
expect(expect('bar').foo('bar')).to.be.an.instanceOf(assertionConstructor);
});

it('addChainableMethod sets `ssfi` when `keep_ssfi` isn\'t set', function () {
it('addChainableMethod sets `ssfi` when `lockSsfi` isn\'t set', function () {
var origAssertion = expect('x');
var origSsfi = utils.flag(origAssertion, 'ssfi');

Expand All @@ -912,11 +912,11 @@ describe('utilities', function () {
expect(origSsfi).to.not.equal(newSsfi);
});

it('addChainableMethod doesn\'t set `ssfi` when `keep_ssfi` is set', function () {
it('addChainableMethod doesn\'t set `ssfi` when `lockSsfi` is set', function () {
var origAssertion = expect('x');
var origSsfi = utils.flag(origAssertion, 'ssfi');

utils.flag(origAssertion, 'keep_ssfi', true);
utils.flag(origAssertion, 'lockSsfi', true);

var newAssertion = origAssertion.to.be.x();
var newSsfi = utils.flag(newAssertion, 'ssfi');
Expand Down Expand Up @@ -1029,7 +1029,7 @@ describe('utilities', function () {
}
});

it('overwriteChainableMethod sets `ssfi` when `keep_ssfi` isn\'t set', function () {
it('overwriteChainableMethod sets `ssfi` when `lockSsfi` isn\'t set', function () {
var origAssertion = expect('x');
var origSsfi = utils.flag(origAssertion, 'ssfi');

Expand All @@ -1039,11 +1039,11 @@ describe('utilities', function () {
expect(origSsfi).to.not.equal(newSsfi);
});

it('overwriteChainableMethod doesn\'t set `ssfi` when `keep_ssfi` is set', function () {
it('overwriteChainableMethod doesn\'t set `ssfi` when `lockSsfi` is set', function () {
var origAssertion = expect('x');
var origSsfi = utils.flag(origAssertion, 'ssfi');

utils.flag(origAssertion, 'keep_ssfi', true);
utils.flag(origAssertion, 'lockSsfi', true);

var newAssertion = origAssertion.to.be.x();
var newSsfi = utils.flag(newAssertion, 'ssfi');
Expand Down

0 comments on commit 2999156

Please sign in to comment.