Fixed deprecations triggered from within asymmetricEqualityTesterArgCompatShim
This commit is contained in:
@@ -2902,10 +2902,7 @@ getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) {
|
|||||||
matchersUtil,
|
matchersUtil,
|
||||||
customEqualityTesters
|
customEqualityTesters
|
||||||
) {
|
) {
|
||||||
var self = Object.create(matchersUtil),
|
var self = Object.create(matchersUtil);
|
||||||
props,
|
|
||||||
i,
|
|
||||||
k;
|
|
||||||
|
|
||||||
copyAndDeprecate(self, customEqualityTesters, 'length');
|
copyAndDeprecate(self, customEqualityTesters, 'length');
|
||||||
|
|
||||||
@@ -2913,18 +2910,30 @@ getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) {
|
|||||||
copyAndDeprecate(self, customEqualityTesters, i);
|
copyAndDeprecate(self, customEqualityTesters, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
var props = arrayProps();
|
// Avoid copying array props if we've previously done so,
|
||||||
|
// to avoid triggering our own deprecation warnings.
|
||||||
|
if (!self.isAsymmetricEqualityTesterArgCompatShim_) {
|
||||||
|
copyAndDeprecateArrayMethods(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.isAsymmetricEqualityTesterArgCompatShim_ = true;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyAndDeprecateArrayMethods(dest) {
|
||||||
|
var props = arrayProps(),
|
||||||
|
i,
|
||||||
|
k;
|
||||||
|
|
||||||
for (i = 0; i < props.length; i++) {
|
for (i = 0; i < props.length; i++) {
|
||||||
k = props[i];
|
k = props[i];
|
||||||
|
|
||||||
// Skip length (dealt with above), and anything that collides with
|
// Skip length (dealt with above), and anything that collides with
|
||||||
// MatchesUtil e.g. an Array.prototype.contains method added by user code
|
// MatchesUtil e.g. an Array.prototype.contains method added by user code
|
||||||
if (k !== 'length' && !self[k]) {
|
if (k !== 'length' && !dest[k]) {
|
||||||
copyAndDeprecate(self, Array.prototype, k);
|
copyAndDeprecate(dest, Array.prototype, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyAndDeprecate(dest, src, propName) {
|
function copyAndDeprecate(dest, src, propName) {
|
||||||
|
|||||||
@@ -181,4 +181,18 @@ describe('asymmetricEqualityTesterArgCompatShim', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('When the matchersUtil is already an asymmetricEqualityTesterArgCompatShim', function() {
|
||||||
|
it('does not trigger any deprecations', function() {
|
||||||
|
var shim1 = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim(
|
||||||
|
{},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
spyOn(jasmineUnderTest.getEnv(), 'deprecated');
|
||||||
|
|
||||||
|
jasmineUnderTest.asymmetricEqualityTesterArgCompatShim(shim1, []);
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.getEnv().deprecated).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -51,10 +51,7 @@ getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) {
|
|||||||
matchersUtil,
|
matchersUtil,
|
||||||
customEqualityTesters
|
customEqualityTesters
|
||||||
) {
|
) {
|
||||||
var self = Object.create(matchersUtil),
|
var self = Object.create(matchersUtil);
|
||||||
props,
|
|
||||||
i,
|
|
||||||
k;
|
|
||||||
|
|
||||||
copyAndDeprecate(self, customEqualityTesters, 'length');
|
copyAndDeprecate(self, customEqualityTesters, 'length');
|
||||||
|
|
||||||
@@ -62,18 +59,30 @@ getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) {
|
|||||||
copyAndDeprecate(self, customEqualityTesters, i);
|
copyAndDeprecate(self, customEqualityTesters, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
var props = arrayProps();
|
// Avoid copying array props if we've previously done so,
|
||||||
|
// to avoid triggering our own deprecation warnings.
|
||||||
|
if (!self.isAsymmetricEqualityTesterArgCompatShim_) {
|
||||||
|
copyAndDeprecateArrayMethods(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.isAsymmetricEqualityTesterArgCompatShim_ = true;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyAndDeprecateArrayMethods(dest) {
|
||||||
|
var props = arrayProps(),
|
||||||
|
i,
|
||||||
|
k;
|
||||||
|
|
||||||
for (i = 0; i < props.length; i++) {
|
for (i = 0; i < props.length; i++) {
|
||||||
k = props[i];
|
k = props[i];
|
||||||
|
|
||||||
// Skip length (dealt with above), and anything that collides with
|
// Skip length (dealt with above), and anything that collides with
|
||||||
// MatchesUtil e.g. an Array.prototype.contains method added by user code
|
// MatchesUtil e.g. an Array.prototype.contains method added by user code
|
||||||
if (k !== 'length' && !self[k]) {
|
if (k !== 'length' && !dest[k]) {
|
||||||
copyAndDeprecate(self, Array.prototype, k);
|
copyAndDeprecate(dest, Array.prototype, k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyAndDeprecate(dest, src, propName) {
|
function copyAndDeprecate(dest, src, propName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user