Removed deprecated custom matcher, matchersUtil, pp, etc interfaces

This commit is contained in:
Steve Gravrock
2020-02-12 15:38:52 -08:00
committed by Steve Gravrock
parent 66189d742b
commit 4b2a14f1f3
11 changed files with 33 additions and 1169 deletions

View File

@@ -72,40 +72,9 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
j$.Expectation = jRequire.Expectation(j$);
j$.buildExpectationResult = jRequire.buildExpectationResult(j$);
j$.JsApiReporter = jRequire.JsApiReporter(j$);
j$.asymmetricEqualityTesterArgCompatShim = jRequire.asymmetricEqualityTesterArgCompatShim(
j$
);
j$.makePrettyPrinter = jRequire.makePrettyPrinter(j$);
j$.basicPrettyPrinter_ = j$.makePrettyPrinter();
Object.defineProperty(j$, 'pp', {
get: function() {
j$.getEnv().deprecatedOnceWithStack(
'jasmine.pp is deprecated and will be removed in a future release. ' +
'Use the pp method of the matchersUtil passed to the matcher factory ' +
"or the asymmetric equality tester's `asymmetricMatch` method " +
'instead. See ' +
'<https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
return j$.basicPrettyPrinter_;
}
});
j$.MatchersUtil = jRequire.MatchersUtil(j$);
var staticMatchersUtil = new j$.MatchersUtil({
customTesters: [],
pp: j$.basicPrettyPrinter_
});
Object.defineProperty(j$, 'matchersUtil', {
get: function() {
j$.getEnv().deprecatedOnceWithStack(
'jasmine.matchersUtil is deprecated and will be removed ' +
'in a future release. Use the instance passed to the matcher factory or ' +
"the asymmetric equality tester's `asymmetricMatch` method instead. " +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
return staticMatchersUtil;
}
});
j$.ObjectContaining = jRequire.ObjectContaining(j$);
j$.ArrayContaining = jRequire.ArrayContaining(j$);
j$.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$);
@@ -1304,17 +1273,6 @@ getJasmineRequireObj().Env = function(j$) {
runnableResources[currentRunnable().id].customMatchers;
for (var matcherName in matchersToAdd) {
if (matchersToAdd[matcherName].length > 1) {
self.deprecatedOnceWithStack(
'The matcher factory for "' +
matcherName +
'" ' +
'accepts custom equality testers, but this parameter will no longer be ' +
'passed in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
customMatchers[matcherName] = matchersToAdd[matcherName];
}
};
@@ -1329,17 +1287,6 @@ getJasmineRequireObj().Env = function(j$) {
runnableResources[currentRunnable().id].customAsyncMatchers;
for (var matcherName in matchersToAdd) {
if (matchersToAdd[matcherName].length > 1) {
self.deprecatedOnceWithStack(
'The matcher factory for "' +
matcherName +
'" ' +
'accepts custom equality testers, but this parameter will no longer be ' +
'passed in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
customAsyncMatchers[matcherName] = matchersToAdd[matcherName];
}
};
@@ -1385,12 +1332,8 @@ getJasmineRequireObj().Env = function(j$) {
};
var expectationFactory = function(actual, spec) {
var customEqualityTesters =
runnableResources[spec.id].customEqualityTesters;
return j$.Expectation.factory({
matchersUtil: makeMatchersUtil(),
customEqualityTesters: customEqualityTesters,
customMatchers: runnableResources[spec.id].customMatchers,
actual: actual,
addExpectationResult: addExpectationResult
@@ -1430,7 +1373,6 @@ getJasmineRequireObj().Env = function(j$) {
var asyncExpectationFactory = function(actual, spec, runableType) {
return j$.Expectation.asyncFactory({
matchersUtil: makeMatchersUtil(),
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
actual: actual,
addExpectationResult: addExpectationResult
@@ -2932,129 +2874,6 @@ getJasmineRequireObj().Truthy = function(j$) {
return Truthy;
};
getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) {
/*
Older versions of Jasmine passed an array of custom equality testers as the
second argument to each asymmetric equality tester's `asymmetricMatch`
method. Newer versions will pass a `MatchersUtil` instance. The
asymmetricEqualityTesterArgCompatShim allows for a graceful migration from
the old interface to the new by "being" both an array of custom equality
testers and a `MatchersUtil` at the same time.
This code should be removed in the next major release.
*/
var likelyArrayProps = [
'concat',
'constructor',
'copyWithin',
'entries',
'every',
'fill',
'filter',
'find',
'findIndex',
'flat',
'flatMap',
'forEach',
'includes',
'indexOf',
'join',
'keys',
'lastIndexOf',
'length',
'map',
'pop',
'push',
'reduce',
'reduceRight',
'reverse',
'shift',
'slice',
'some',
'sort',
'splice',
'toLocaleString',
'toSource',
'toString',
'unshift',
'values'
];
function asymmetricEqualityTesterArgCompatShim(
matchersUtil,
customEqualityTesters
) {
var self = Object.create(matchersUtil);
copyAndDeprecate(self, customEqualityTesters, 'length');
for (i = 0; i < customEqualityTesters.length; i++) {
copyAndDeprecate(self, customEqualityTesters, i);
}
// 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++) {
k = props[i];
// Skip length (dealt with above), and anything that collides with
// MatchesUtil e.g. an Array.prototype.contains method added by user code
if (k !== 'length' && !dest[k]) {
copyAndDeprecate(dest, Array.prototype, k);
}
}
}
function copyAndDeprecate(dest, src, propName) {
Object.defineProperty(dest, propName, {
get: function() {
j$.getEnv().deprecated(
'The second argument to asymmetricMatch is now a ' +
'MatchersUtil. Using it as an array of custom equality testers is ' +
'deprecated and will stop working in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
return src[propName];
}
});
}
function arrayProps() {
var props, a, k;
if (!Object.getOwnPropertyDescriptors) {
return likelyArrayProps.filter(function(k) {
return Array.prototype.hasOwnProperty(k);
});
}
props = Object.getOwnPropertyDescriptors(Array.prototype); // eslint-disable-line compat/compat
a = [];
for (k in props) {
a.push(k);
}
return a;
}
return asymmetricEqualityTesterArgCompatShim;
};
getJasmineRequireObj().CallTracker = function(j$) {
/**
* @namespace Spy#calls
@@ -4128,7 +3947,6 @@ getJasmineRequireObj().Expector = function(j$) {
this.matchersUtil = options.matchersUtil || {
buildFailureMessage: function() {}
};
this.customEqualityTesters = options.customEqualityTesters || [];
this.actual = options.actual;
this.addExpectationResult = options.addExpectationResult || function() {};
this.filters = new j$.ExpectationFilterChain();
@@ -4145,14 +3963,7 @@ getJasmineRequireObj().Expector = function(j$) {
this.args.unshift(this.actual);
// TODO: Remove support for passing customEqualityTesters in the next major release.
var matcher;
if (matcherFactory.length >= 2) {
matcher = matcherFactory(this.matchersUtil, this.customEqualityTesters);
} else {
matcher = matcherFactory(this.matchersUtil);
}
var matcher = matcherFactory(this.matchersUtil);
var comparisonFunc = this.filters.selectComparisonFunc(matcher);
return comparisonFunc || matcher.compare;
@@ -4851,19 +4662,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
* @since 2.0.0
* @param {*} haystack The collection to search
* @param {*} needle The value to search for
* @param [customTesters] An array of custom equality testers. Deprecated.
* As of 3.6 this parameter no longer needs to be passed. It will be removed in 4.0.
* @returns {boolean} True if `needle` was found in `haystack`
*/
MatchersUtil.prototype.contains = function(haystack, needle, customTesters) {
if (customTesters) {
j$.getEnv().deprecatedOnceWithStack(
'Passing custom equality testers ' +
'to MatchersUtil#contains is deprecated. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
MatchersUtil.prototype.contains = function(haystack, needle) {
if (j$.isSet(haystack)) {
return haystack.has(needle);
}
@@ -4873,7 +4674,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
(!!haystack && !haystack.indexOf)
) {
for (var i = 0; i < haystack.length; i++) {
if (this.equals(haystack[i], needle, customTesters)) {
if (this.equals(haystack[i], needle)) {
return true;
}
}
@@ -4917,19 +4718,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
if (j$.isFunction_(b.valuesForDiff_)) {
var values = b.valuesForDiff_(a, this.pp);
this.eq_(
values.other,
values.self,
aStack,
bStack,
customTesters,
diffBuilder
);
this.eq_(values.other, values.self, aStack, bStack, diffBuilder);
} else {
diffBuilder.recordMismatch();
}
@@ -4940,22 +4733,18 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
var asymmetricA = j$.isAsymmetricEqualityTester_(a),
asymmetricB = j$.isAsymmetricEqualityTester_(b),
shim,
result;
if (asymmetricA === asymmetricB) {
return undefined;
}
shim = j$.asymmetricEqualityTesterArgCompatShim(this, customTesters);
if (asymmetricA) {
result = a.asymmetricMatch(b, shim);
result = a.asymmetricMatch(b, this);
if (!result) {
diffBuilder.recordMismatch();
}
@@ -4963,9 +4752,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
}
if (asymmetricB) {
result = b.asymmetricMatch(a, shim);
result = b.asymmetricMatch(a, this);
if (!result) {
this.asymmetricDiff_(a, b, aStack, bStack, customTesters, diffBuilder);
this.asymmetricDiff_(a, b, aStack, bStack, diffBuilder);
}
return result;
}
@@ -4978,58 +4767,18 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
* @since 2.0.0
* @param {*} a The first value to compare
* @param {*} b The second value to compare
* @param [customTesters] An array of custom equality testers. Deprecated.
* As of 3.6 this parameter no longer needs to be passed. It will be removed in 4.0.
* @returns {boolean} True if the values are equal
*/
MatchersUtil.prototype.equals = function(
a,
b,
customTestersOrDiffBuilder,
diffBuilderOrNothing
) {
var customTesters, diffBuilder;
if (isDiffBuilder(customTestersOrDiffBuilder)) {
diffBuilder = customTestersOrDiffBuilder;
} else {
if (customTestersOrDiffBuilder) {
j$.getEnv().deprecatedOnceWithStack(
'Passing custom equality testers ' +
'to MatchersUtil#equals is deprecated. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
if (diffBuilderOrNothing) {
j$.getEnv().deprecatedOnceWithStack(
'Diff builder should be passed ' +
'as the third argument to MatchersUtil#equals, not the fourth. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
customTesters = customTestersOrDiffBuilder;
diffBuilder = diffBuilderOrNothing;
}
customTesters = customTesters || this.customTesters_;
MatchersUtil.prototype.equals = function(a, b, diffBuilder) {
diffBuilder = diffBuilder || j$.NullDiffBuilder();
diffBuilder.setRoots(a, b);
return this.eq_(a, b, [], [], customTesters, diffBuilder);
return this.eq_(a, b, [], [], diffBuilder);
};
// Equality function lovingly adapted from isEqual in
// [Underscore](http://underscorejs.org)
MatchersUtil.prototype.eq_ = function(
a,
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
MatchersUtil.prototype.eq_ = function(a, b, aStack, bStack, diffBuilder) {
var result = true,
self = this,
i;
@@ -5039,15 +4788,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
b,
aStack,
bStack,
customTesters,
diffBuilder
);
if (!j$.util.isUndefined(asymmetricResult)) {
return asymmetricResult;
}
for (i = 0; i < customTesters.length; i++) {
var customTesterResult = customTesters[i](a, b);
for (i = 0; i < this.customTesters_.length; i++) {
var customTesterResult = this.customTesters_[i](a, b);
if (!j$.util.isUndefined(customTesterResult)) {
if (!customTesterResult) {
diffBuilder.recordMismatch();
@@ -5123,7 +4871,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
new Uint8Array(b), // eslint-disable-line compat/compat
aStack,
bStack,
customTesters,
diffBuilder
);
// RegExps are compared by their source patterns and flags.
@@ -5202,7 +4949,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
i < bLength ? b[i] : void 0,
aStack,
bStack,
customTesters,
diffBuilder
) && result;
}
@@ -5247,14 +4993,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
if (
j$.isAsymmetricEqualityTester_(mapKey) ||
(j$.isAsymmetricEqualityTester_(cmpKey) &&
this.eq_(
mapKey,
cmpKey,
aStack,
bStack,
customTesters,
j$.NullDiffBuilder()
))
this.eq_(mapKey, cmpKey, aStack, bStack, j$.NullDiffBuilder()))
) {
mapValueB = b.get(cmpKey);
} else {
@@ -5265,7 +5004,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
mapValueB,
aStack,
bStack,
customTesters,
j$.NullDiffBuilder()
);
}
@@ -5316,7 +5054,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
otherValue,
baseStack,
otherStack,
customTesters,
j$.NullDiffBuilder()
);
if (!found && prevStackSize !== baseStack.length) {
@@ -5381,9 +5118,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
}
diffBuilder.withPath(key, function() {
if (
!self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)
) {
if (!self.eq_(a[key], b[key], aStack, bStack, diffBuilder)) {
result = false;
}
});
@@ -5495,10 +5230,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return formatted;
}
function isDiffBuilder(obj) {
return obj && typeof obj.recordMismatch === 'function';
}
return MatchersUtil;
};

View File

@@ -55,43 +55,6 @@ describe('Expectation', function() {
expect(matcherFactory).toHaveBeenCalledWith(matchersUtil);
});
// TODO: remove this in the next major release
it('passes custom equality testers when the matcher factory takes two arguments', function() {
var fakeCompare = function() {
return { pass: true };
},
matcherFactory = function(matchersUtil, customTesters) {
return { compare: fakeCompare };
},
matcherFactorySpy = jasmine
.createSpy('matcher', matcherFactory)
.and.callThrough(),
matchers = {
toFoo: matcherFactorySpy
},
matchersUtil = {
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
},
customEqualityTesters = ['a'],
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
expectation = jasmineUnderTest.Expectation.factory({
matchersUtil: matchersUtil,
customMatchers: matchers,
customEqualityTesters: customEqualityTesters,
actual: 'an actual',
addExpectationResult: addExpectationResult
});
expectation.toFoo('hello');
expect(matcherFactorySpy).toHaveBeenCalledWith(
matchersUtil,
customEqualityTesters
);
});
it("wraps matchers's compare functions, passing the actual and expected", function() {
var fakeCompare = jasmine
.createSpy('fake-compare')

View File

@@ -1,197 +0,0 @@
describe('asymmetricEqualityTesterArgCompatShim', function() {
it('provides all the properties of the MatchersUtil', function() {
var matchersUtil = {
foo: function() {},
bar: function() {}
},
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim(
matchersUtil,
[]
);
expect(shim.foo).toBe(matchersUtil.foo);
expect(shim.bar).toBe(matchersUtil.bar);
});
it('provides and deprecates all the properties of the customEqualityTesters', function() {
var customEqualityTesters = [function() {}, function() {}],
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim(
{},
customEqualityTesters
),
deprecated = spyOn(jasmineUnderTest.getEnv(), 'deprecated'),
expectedMessage =
'The second argument to asymmetricMatch is now a MatchersUtil. ' +
'Using it as an array of custom equality testers is deprecated and will stop ' +
'working in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.';
expect(shim.length).toBe(2);
expect(deprecated).toHaveBeenCalledWith(expectedMessage);
deprecated.calls.reset();
expect(shim[0]).toBe(customEqualityTesters[0]);
expect(deprecated).toHaveBeenCalledWith(expectedMessage);
deprecated.calls.reset();
expect(shim[1]).toBe(customEqualityTesters[1]);
expect(deprecated).toHaveBeenCalledWith(expectedMessage);
});
it('provides and deprecates all the properties of Array.prototype', function() {
var shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim({}, []),
deprecated = spyOn(jasmineUnderTest.getEnv(), 'deprecated'),
expectedMessage =
'The second argument to asymmetricMatch is now a MatchersUtil. ' +
'Using it as an array of custom equality testers is deprecated and will stop ' +
'working in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.';
expect(shim.filter).toBe(Array.prototype.filter);
expect(deprecated).toHaveBeenCalledWith(expectedMessage);
deprecated.calls.reset();
expect(shim.forEach).toBe(Array.prototype.forEach);
expect(deprecated).toHaveBeenCalledWith(expectedMessage);
deprecated.calls.reset();
expect(shim.map).toBe(Array.prototype.map);
expect(deprecated).toHaveBeenCalledWith(expectedMessage);
deprecated.calls.reset();
});
it('provides and deprecates properties of Array.prototype', function() {
var keys = [
'concat',
'every',
'filter',
'forEach',
'indexOf',
'join',
'lastIndexOf',
'length',
'map',
'pop',
'push',
'reduce',
'reduceRight',
'reverse',
'shift',
'slice',
'some',
'sort',
'splice',
'unshift'
],
optionalKeys = [
'copyWithin',
'entries',
'fill',
'find',
'findIndex',
'flat',
'flatMap',
'includes',
'keys',
'values'
],
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim({}, []),
deprecated = spyOn(jasmineUnderTest.getEnv(), 'deprecated'),
i,
k;
// Properties that are present on all supported runtimes
for (i = 0; i < keys.length; i++) {
k = keys[i];
expect(shim[k])
.withContext(k)
.not.toBeUndefined();
expect(shim[k])
.withContext(k)
.toBe(Array.prototype[k]);
expect(deprecated).toHaveBeenCalled();
deprecated.calls.reset();
}
// Properties that are present on only some supported runtimes
for (i = 0; i < optionalKeys.length; i++) {
k = optionalKeys[i];
if (shim[k] !== undefined) {
expect(shim[k])
.withContext(k)
.toBe(Array.prototype[k]);
expect(deprecated)
.withContext(k)
.toHaveBeenCalled();
deprecated.calls.reset();
}
}
});
it('does not deprecate properties of Object.prototype', function() {
var shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim({}, []),
deprecated = spyOn(jasmineUnderTest.getEnv(), 'deprecated');
expect(shim.hasOwnProperty).toBe(Object.prototype.hasOwnProperty);
expect(shim.isPrototypeOf).toBe(Object.prototype.isPrototypeOf);
expect(deprecated).not.toHaveBeenCalled();
});
describe('When Array.prototype additions collide with MatchersUtil methods', function() {
function keys() {
return [
'contains',
'buildFailureMessage',
'asymmetricDiff_',
'asymmetricMatch_',
'equals',
'eq_'
];
}
beforeEach(function() {
keys().forEach(function(k) {
expect(Array.prototype[k])
.withContext('Array.prototype already had ' + k)
.toBeUndefined();
Array.prototype[k] = function() {};
});
});
afterEach(function() {
keys().forEach(function(k) {
delete Array.prototype[k];
});
});
it('uses the MatchersUtil methods', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil({}),
shim = jasmineUnderTest.asymmetricEqualityTesterArgCompatShim(
matchersUtil,
[]
);
keys().forEach(function(k) {
expect(shim[k])
.withContext(k + ' was overwritten')
.toBe(jasmineUnderTest.MatchersUtil.prototype[k]);
});
});
});
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();
});
});
});

View File

@@ -124,48 +124,6 @@ describe('Custom Async Matchers (Integration)', function() {
env.execute(null, done);
});
// TODO: remove this in the next major release.
describe('When a matcher factory takes at least two arguments', function() {
it('passes the jasmine utility and current equality testers to the matcher factory', function(done) {
jasmine.getEnv().requirePromises();
var matcherFactory = function(util, customTesters) {
return {
compare: function() {
return Promise.resolve({ pass: true });
}
};
},
matcherFactorySpy = jasmine.createSpy(
'matcherFactorySpy',
matcherFactory
),
customEqualityFn = function() {
return true;
};
env.it('spec with expectation', function() {
env.addCustomEqualityTester(customEqualityFn);
env.addAsyncMatchers({
toBeReal: matcherFactorySpy
});
return env.expectAsync(true).toBeReal();
});
var specExpectations = function() {
expect(matcherFactorySpy).toHaveBeenCalledWith(
jasmine.any(jasmineUnderTest.MatchersUtil),
[customEqualityFn]
);
};
spyOn(env, 'deprecated');
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
});
it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
jasmine.getEnv().requirePromises();
@@ -201,42 +159,4 @@ describe('Custom Async Matchers (Integration)', function() {
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('logs a deprecation once per matcher if the matcher factory takes two arguments', function(done) {
var matcherFactory = function(matchersUtil, customEqualityTesters) {
return { compare: function() {} };
};
spyOn(env, 'deprecated');
env.beforeEach(function() {
env.addAsyncMatchers({ toBeFoo: matcherFactory });
env.addAsyncMatchers({ toBeBar: matcherFactory });
});
env.it('a spec', function() {});
env.it('another spec', function() {});
function jasmineDone() {
expect(env.deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
'The matcher factory for "toBeFoo" accepts custom equality testers, ' +
'but this parameter will no longer be passed in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
)
);
expect(env.deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
'The matcher factory for "toBeBar" accepts custom equality testers, ' +
'but this parameter will no longer be passed in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
)
);
expect(env.deprecated).toHaveBeenCalledTimes(2);
done();
}
env.addReporter({ jasmineDone: jasmineDone });
env.execute();
});
});

View File

@@ -108,44 +108,7 @@ describe('Custom Matchers (Integration)', function() {
env.execute(null, done);
});
it('supports asymmetric equality testers that take a list of custom equality testers', function(done) {
// TODO: remove this in the next major release.
spyOn(jasmineUnderTest, 'getEnv').and.returnValue(env);
spyOn(env, 'deprecated'); // suppress warnings
env.it('spec using custom asymmetric equality tester', function() {
var customEqualityFn = function(a, b) {
if (a === 2 && b === 'two') {
return true;
}
};
var arrayWithFirstElement = function(sample) {
return {
asymmetricMatch: function(actual, customEqualityTesters) {
return jasmineUnderTest.matchersUtil.equals(
sample,
actual[0],
customEqualityTesters
);
}
};
};
env.addCustomEqualityTester(customEqualityFn);
env.expect(['two']).toEqual(arrayWithFirstElement(2));
});
var specExpectations = function(result) {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('displays an appropriate failure message if a custom equality matcher fails', function(done) {
spyOn(env, 'deprecated');
env.it('spec using custom equality matcher', function() {
var customEqualityFn = function(a, b) {
// "foo" is not equal to anything
@@ -277,47 +240,6 @@ describe('Custom Matchers (Integration)', function() {
env.execute(null, done);
});
// TODO: remove this in the next major release.
describe('When a matcher factory takes at least two arguments', function() {
it('passes the jasmine utility and current equality testers to the matcher factory', function(done) {
spyOn(env, 'deprecated');
var matcherFactory = function(util, customTesters) {
return {
compare: function() {
return { pass: true };
}
};
},
matcherFactorySpy = jasmine.createSpy(
'matcherFactorySpy',
matcherFactory
),
customEqualityFn = function() {
return true;
};
env.it('spec with expectation', function() {
env.addCustomEqualityTester(customEqualityFn);
env.addMatchers({
toBeReal: matcherFactorySpy
});
env.expect(true).toBeReal();
});
var specExpectations = function() {
expect(matcherFactorySpy).toHaveBeenCalledWith(
jasmine.any(jasmineUnderTest.MatchersUtil),
[customEqualityFn]
);
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
});
});
it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
var matcherFactory = function(matchersUtil) {
return {
@@ -349,42 +271,4 @@ describe('Custom Matchers (Integration)', function() {
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('logs a deprecation once per matcher if the matcher factory takes two arguments', function(done) {
var matcherFactory = function(matchersUtil, customEqualityTesters) {
return { compare: function() {} };
};
spyOn(env, 'deprecated');
env.beforeEach(function() {
env.addMatchers({ toBeFoo: matcherFactory });
env.addMatchers({ toBeBar: matcherFactory });
});
env.it('a spec', function() {});
env.it('another spec', function() {});
function jasmineDone() {
expect(env.deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
'The matcher factory for "toBeFoo" accepts custom equality testers, ' +
'but this parameter will no longer be passed in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
)
);
expect(env.deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
'The matcher factory for "toBeBar" accepts custom equality testers, ' +
'but this parameter will no longer be passed in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
)
);
expect(env.deprecated).toHaveBeenCalledTimes(2);
done();
}
env.addReporter({ jasmineDone: jasmineDone });
env.execute();
});
});

View File

@@ -499,19 +499,7 @@ describe('matchersUtil', function() {
).toBe(true);
});
it('passes when a custom equality matcher passed to equals returns true', function() {
// TODO: remove this in the next major release.
var tester = function(a, b) {
return true;
},
matchersUtil = new jasmineUnderTest.MatchersUtil();
spyOn(jasmineUnderTest.getEnv(), 'deprecated'); // suppress warning
expect(matchersUtil.equals(1, 2, [tester])).toBe(true);
});
it('passes when a custom equality matcher passed to the constructor returns true', function() {
it('passes when a custom equality matcher returns true', function() {
var tester = function(a, b) {
return true;
},
@@ -528,20 +516,7 @@ describe('matchersUtil', function() {
expect(matchersUtil.equals({}, {})).toBe(true);
});
describe("when a custom equality matcher is passed to equals that returns 'undefined'", function() {
// TODO: remove this in the next major release.
var tester = function(a, b) {
return jasmine.undefined;
};
it('passes for two empty Objects', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil();
spyOn(jasmineUnderTest.getEnv(), 'deprecated'); // suppress warning
expect(matchersUtil.equals({}, {}, [tester])).toBe(true);
});
});
describe("when a custom equality matcher is passed to the constructor that returns 'undefined'", function() {
describe("when a custom equality matcher returns 'undefined'", function() {
var tester = function(a, b) {
return jasmine.undefined;
};
@@ -555,19 +530,7 @@ describe('matchersUtil', function() {
});
});
it('fails for equivalents when a custom equality matcher passed to equals returns false', function() {
// TODO: remove this in the next major release.
var tester = function(a, b) {
return false;
},
matchersUtil = new jasmineUnderTest.MatchersUtil();
spyOn(jasmineUnderTest.getEnv(), 'deprecated'); // suppress warning
expect(matchersUtil.equals(1, 1, [tester])).toBe(false);
});
it('fails for equivalents when a custom equality matcher passed to the constructor returns false', function() {
it('fails for equivalents when a custom equality matcher returns false', function() {
var tester = function(a, b) {
return false;
},
@@ -579,29 +542,7 @@ describe('matchersUtil', function() {
expect(matchersUtil.equals(1, 1)).toBe(false);
});
it('passes for an asymmetric equality tester that returns true when a custom equality tester passed to equals return false', function() {
// TODO: remove this in the next major release.
var asymmetricTester = {
asymmetricMatch: function(other) {
return true;
}
},
symmetricTester = function(a, b) {
return false;
},
matchersUtil = new jasmineUnderTest.MatchersUtil();
spyOn(jasmineUnderTest.getEnv(), 'deprecated'); // suppress warning
expect(
matchersUtil.equals(asymmetricTester, true, [symmetricTester])
).toBe(true);
expect(
matchersUtil.equals(true, asymmetricTester, [symmetricTester])
).toBe(true);
});
it('passes for an asymmetric equality tester that returns true when a custom equality tester passed to the constructor return false', function() {
it('passes for an asymmetric equality tester that returns true when a custom equality tester return false', function() {
var asymmetricTester = {
asymmetricMatch: function(other) {
return true;
@@ -619,47 +560,6 @@ describe('matchersUtil', function() {
expect(matchersUtil.equals(true, asymmetricTester)).toBe(true);
});
describe('The compatibility shim passed to asymmetric equality testers', function() {
describe('When equals is called with custom equality testers', function() {
it('is both a matchersUtil and the custom equality testers passed to equals', function() {
var asymmetricTester = jasmine.createSpyObj('tester', [
'asymmetricMatch'
]),
symmetricTester = function() {},
matchersUtil = new jasmineUnderTest.MatchersUtil(),
shim;
spyOn(jasmineUnderTest.getEnv(), 'deprecated'); // suppress warning
matchersUtil.equals(true, asymmetricTester, [symmetricTester]);
shim = asymmetricTester.asymmetricMatch.calls.argsFor(0)[1];
expect(shim).toEqual(jasmine.any(jasmineUnderTest.MatchersUtil));
expect(shim.length).toEqual(1);
expect(shim[0]).toEqual(symmetricTester);
});
});
describe('When equals is called with custom equality testers', function() {
it('is both a matchersUtil and the custom equality testers passed to the constructor', function() {
var asymmetricTester = jasmine.createSpyObj('tester', [
'asymmetricMatch'
]),
symmetricTester = function() {},
matchersUtil = new jasmineUnderTest.MatchersUtil({
customTesters: [symmetricTester],
pp: function() {}
}),
shim;
spyOn(jasmineUnderTest.getEnv(), 'deprecated'); // suppress warning
matchersUtil.equals(true, asymmetricTester);
shim = asymmetricTester.asymmetricMatch.calls.argsFor(0)[1];
expect(shim).toEqual(jasmine.any(jasmineUnderTest.MatchersUtil));
expect(shim.length).toEqual(1);
expect(shim[0]).toEqual(symmetricTester);
});
});
});
it('passes when an Any is compared to an Any that checks for the same type', function() {
var any1 = new jasmineUnderTest.Any(Function),
any2 = new jasmineUnderTest.Any(Function),
@@ -1030,57 +930,6 @@ describe('matchersUtil', function() {
});
});
it('logs a deprecation warning when custom equality testers are passed', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
deprecated = spyOn(jasmineUnderTest.getEnv(), 'deprecated');
matchersUtil.equals(0, 0, []);
expect(deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
'Passing custom equality testers ' +
'to MatchersUtil#equals is deprecated. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
)
);
});
it('logs a deprecation warning when a diffBuilder is provided as the fourth argument', function() {
var matchersUtil = new jasmineUnderTest.MatchersUtil(),
deprecated = spyOn(jasmineUnderTest.getEnv(), 'deprecated');
matchersUtil.equals(0, 0, null, new jasmineUnderTest.NullDiffBuilder());
expect(deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
'Diff builder should be passed as the ' +
'third argument to MatchersUtil#equals, not the fourth. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
)
);
});
it('uses a diffBuilder if one is provided as the fourth argument', function() {
// TODO: remove this in the next major release.
var diffBuilder = new jasmineUnderTest.DiffBuilder(),
matchersUtil = new jasmineUnderTest.MatchersUtil();
spyOn(jasmineUnderTest.getEnv(), 'deprecated'); // suppress warning
spyOn(diffBuilder, 'recordMismatch');
spyOn(diffBuilder, 'withPath').and.callThrough();
matchersUtil.equals([1], [2], [], diffBuilder);
expect(diffBuilder.withPath).toHaveBeenCalledWith(
'length',
jasmine.any(Function)
);
expect(diffBuilder.withPath).toHaveBeenCalledWith(
0,
jasmine.any(Function)
);
expect(diffBuilder.recordMismatch).toHaveBeenCalledWith();
});
it('uses a diffBuilder if one is provided as the third argument', function() {
var diffBuilder = new jasmineUnderTest.DiffBuilder(),
matchersUtil = new jasmineUnderTest.MatchersUtil();
@@ -1130,25 +979,7 @@ describe('matchersUtil', function() {
).toBe(true);
});
it('uses custom equality testers if passed to contains and actual is an Array', function() {
// TODO: remove this in the next major release.
var customTester = function(a, b) {
return true;
},
matchersUtil = new jasmineUnderTest.MatchersUtil(),
deprecated = spyOn(jasmineUnderTest.getEnv(), 'deprecated');
expect(matchersUtil.contains([1, 2], 3, [customTester])).toBe(true);
expect(deprecated).toHaveBeenCalledWith(
jasmine.stringMatching(
'Passing custom equality testers to MatchersUtil#contains is deprecated. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
)
);
});
it('uses custom equality testers if passed to the constructor and actual is an Array', function() {
it('uses custom equality testers if actual is an Array', function() {
var customTester = function(a, b) {
return true;
},

View File

@@ -302,17 +302,6 @@ getJasmineRequireObj().Env = function(j$) {
runnableResources[currentRunnable().id].customMatchers;
for (var matcherName in matchersToAdd) {
if (matchersToAdd[matcherName].length > 1) {
self.deprecatedOnceWithStack(
'The matcher factory for "' +
matcherName +
'" ' +
'accepts custom equality testers, but this parameter will no longer be ' +
'passed in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
customMatchers[matcherName] = matchersToAdd[matcherName];
}
};
@@ -327,17 +316,6 @@ getJasmineRequireObj().Env = function(j$) {
runnableResources[currentRunnable().id].customAsyncMatchers;
for (var matcherName in matchersToAdd) {
if (matchersToAdd[matcherName].length > 1) {
self.deprecatedOnceWithStack(
'The matcher factory for "' +
matcherName +
'" ' +
'accepts custom equality testers, but this parameter will no longer be ' +
'passed in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
customAsyncMatchers[matcherName] = matchersToAdd[matcherName];
}
};
@@ -383,12 +361,8 @@ getJasmineRequireObj().Env = function(j$) {
};
var expectationFactory = function(actual, spec) {
var customEqualityTesters =
runnableResources[spec.id].customEqualityTesters;
return j$.Expectation.factory({
matchersUtil: makeMatchersUtil(),
customEqualityTesters: customEqualityTesters,
customMatchers: runnableResources[spec.id].customMatchers,
actual: actual,
addExpectationResult: addExpectationResult
@@ -428,7 +402,6 @@ getJasmineRequireObj().Env = function(j$) {
var asyncExpectationFactory = function(actual, spec, runableType) {
return j$.Expectation.asyncFactory({
matchersUtil: makeMatchersUtil(),
customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
customAsyncMatchers: runnableResources[spec.id].customAsyncMatchers,
actual: actual,
addExpectationResult: addExpectationResult

View File

@@ -3,7 +3,6 @@ getJasmineRequireObj().Expector = function(j$) {
this.matchersUtil = options.matchersUtil || {
buildFailureMessage: function() {}
};
this.customEqualityTesters = options.customEqualityTesters || [];
this.actual = options.actual;
this.addExpectationResult = options.addExpectationResult || function() {};
this.filters = new j$.ExpectationFilterChain();
@@ -20,14 +19,7 @@ getJasmineRequireObj().Expector = function(j$) {
this.args.unshift(this.actual);
// TODO: Remove support for passing customEqualityTesters in the next major release.
var matcher;
if (matcherFactory.length >= 2) {
matcher = matcherFactory(this.matchersUtil, this.customEqualityTesters);
} else {
matcher = matcherFactory(this.matchersUtil);
}
var matcher = matcherFactory(this.matchersUtil);
var comparisonFunc = this.filters.selectComparisonFunc(matcher);
return comparisonFunc || matcher.compare;

View File

@@ -1,122 +0,0 @@
getJasmineRequireObj().asymmetricEqualityTesterArgCompatShim = function(j$) {
/*
Older versions of Jasmine passed an array of custom equality testers as the
second argument to each asymmetric equality tester's `asymmetricMatch`
method. Newer versions will pass a `MatchersUtil` instance. The
asymmetricEqualityTesterArgCompatShim allows for a graceful migration from
the old interface to the new by "being" both an array of custom equality
testers and a `MatchersUtil` at the same time.
This code should be removed in the next major release.
*/
var likelyArrayProps = [
'concat',
'constructor',
'copyWithin',
'entries',
'every',
'fill',
'filter',
'find',
'findIndex',
'flat',
'flatMap',
'forEach',
'includes',
'indexOf',
'join',
'keys',
'lastIndexOf',
'length',
'map',
'pop',
'push',
'reduce',
'reduceRight',
'reverse',
'shift',
'slice',
'some',
'sort',
'splice',
'toLocaleString',
'toSource',
'toString',
'unshift',
'values'
];
function asymmetricEqualityTesterArgCompatShim(
matchersUtil,
customEqualityTesters
) {
var self = Object.create(matchersUtil);
copyAndDeprecate(self, customEqualityTesters, 'length');
for (i = 0; i < customEqualityTesters.length; i++) {
copyAndDeprecate(self, customEqualityTesters, i);
}
// 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++) {
k = props[i];
// Skip length (dealt with above), and anything that collides with
// MatchesUtil e.g. an Array.prototype.contains method added by user code
if (k !== 'length' && !dest[k]) {
copyAndDeprecate(dest, Array.prototype, k);
}
}
}
function copyAndDeprecate(dest, src, propName) {
Object.defineProperty(dest, propName, {
get: function() {
j$.getEnv().deprecated(
'The second argument to asymmetricMatch is now a ' +
'MatchersUtil. Using it as an array of custom equality testers is ' +
'deprecated and will stop working in a future release. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
return src[propName];
}
});
}
function arrayProps() {
var props, a, k;
if (!Object.getOwnPropertyDescriptors) {
return likelyArrayProps.filter(function(k) {
return Array.prototype.hasOwnProperty(k);
});
}
props = Object.getOwnPropertyDescriptors(Array.prototype); // eslint-disable-line compat/compat
a = [];
for (k in props) {
a.push(k);
}
return a;
}
return asymmetricEqualityTesterArgCompatShim;
};

View File

@@ -29,19 +29,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
* @since 2.0.0
* @param {*} haystack The collection to search
* @param {*} needle The value to search for
* @param [customTesters] An array of custom equality testers. Deprecated.
* As of 3.6 this parameter no longer needs to be passed. It will be removed in 4.0.
* @returns {boolean} True if `needle` was found in `haystack`
*/
MatchersUtil.prototype.contains = function(haystack, needle, customTesters) {
if (customTesters) {
j$.getEnv().deprecatedOnceWithStack(
'Passing custom equality testers ' +
'to MatchersUtil#contains is deprecated. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
MatchersUtil.prototype.contains = function(haystack, needle) {
if (j$.isSet(haystack)) {
return haystack.has(needle);
}
@@ -51,7 +41,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
(!!haystack && !haystack.indexOf)
) {
for (var i = 0; i < haystack.length; i++) {
if (this.equals(haystack[i], needle, customTesters)) {
if (this.equals(haystack[i], needle)) {
return true;
}
}
@@ -95,19 +85,11 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
if (j$.isFunction_(b.valuesForDiff_)) {
var values = b.valuesForDiff_(a, this.pp);
this.eq_(
values.other,
values.self,
aStack,
bStack,
customTesters,
diffBuilder
);
this.eq_(values.other, values.self, aStack, bStack, diffBuilder);
} else {
diffBuilder.recordMismatch();
}
@@ -118,22 +100,18 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
var asymmetricA = j$.isAsymmetricEqualityTester_(a),
asymmetricB = j$.isAsymmetricEqualityTester_(b),
shim,
result;
if (asymmetricA === asymmetricB) {
return undefined;
}
shim = j$.asymmetricEqualityTesterArgCompatShim(this, customTesters);
if (asymmetricA) {
result = a.asymmetricMatch(b, shim);
result = a.asymmetricMatch(b, this);
if (!result) {
diffBuilder.recordMismatch();
}
@@ -141,9 +119,9 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
}
if (asymmetricB) {
result = b.asymmetricMatch(a, shim);
result = b.asymmetricMatch(a, this);
if (!result) {
this.asymmetricDiff_(a, b, aStack, bStack, customTesters, diffBuilder);
this.asymmetricDiff_(a, b, aStack, bStack, diffBuilder);
}
return result;
}
@@ -156,58 +134,18 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
* @since 2.0.0
* @param {*} a The first value to compare
* @param {*} b The second value to compare
* @param [customTesters] An array of custom equality testers. Deprecated.
* As of 3.6 this parameter no longer needs to be passed. It will be removed in 4.0.
* @returns {boolean} True if the values are equal
*/
MatchersUtil.prototype.equals = function(
a,
b,
customTestersOrDiffBuilder,
diffBuilderOrNothing
) {
var customTesters, diffBuilder;
if (isDiffBuilder(customTestersOrDiffBuilder)) {
diffBuilder = customTestersOrDiffBuilder;
} else {
if (customTestersOrDiffBuilder) {
j$.getEnv().deprecatedOnceWithStack(
'Passing custom equality testers ' +
'to MatchersUtil#equals is deprecated. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
if (diffBuilderOrNothing) {
j$.getEnv().deprecatedOnceWithStack(
'Diff builder should be passed ' +
'as the third argument to MatchersUtil#equals, not the fourth. ' +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
}
customTesters = customTestersOrDiffBuilder;
diffBuilder = diffBuilderOrNothing;
}
customTesters = customTesters || this.customTesters_;
MatchersUtil.prototype.equals = function(a, b, diffBuilder) {
diffBuilder = diffBuilder || j$.NullDiffBuilder();
diffBuilder.setRoots(a, b);
return this.eq_(a, b, [], [], customTesters, diffBuilder);
return this.eq_(a, b, [], [], diffBuilder);
};
// Equality function lovingly adapted from isEqual in
// [Underscore](http://underscorejs.org)
MatchersUtil.prototype.eq_ = function(
a,
b,
aStack,
bStack,
customTesters,
diffBuilder
) {
MatchersUtil.prototype.eq_ = function(a, b, aStack, bStack, diffBuilder) {
var result = true,
self = this,
i;
@@ -217,15 +155,14 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
b,
aStack,
bStack,
customTesters,
diffBuilder
);
if (!j$.util.isUndefined(asymmetricResult)) {
return asymmetricResult;
}
for (i = 0; i < customTesters.length; i++) {
var customTesterResult = customTesters[i](a, b);
for (i = 0; i < this.customTesters_.length; i++) {
var customTesterResult = this.customTesters_[i](a, b);
if (!j$.util.isUndefined(customTesterResult)) {
if (!customTesterResult) {
diffBuilder.recordMismatch();
@@ -301,7 +238,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
new Uint8Array(b), // eslint-disable-line compat/compat
aStack,
bStack,
customTesters,
diffBuilder
);
// RegExps are compared by their source patterns and flags.
@@ -380,7 +316,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
i < bLength ? b[i] : void 0,
aStack,
bStack,
customTesters,
diffBuilder
) && result;
}
@@ -425,14 +360,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
if (
j$.isAsymmetricEqualityTester_(mapKey) ||
(j$.isAsymmetricEqualityTester_(cmpKey) &&
this.eq_(
mapKey,
cmpKey,
aStack,
bStack,
customTesters,
j$.NullDiffBuilder()
))
this.eq_(mapKey, cmpKey, aStack, bStack, j$.NullDiffBuilder()))
) {
mapValueB = b.get(cmpKey);
} else {
@@ -443,7 +371,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
mapValueB,
aStack,
bStack,
customTesters,
j$.NullDiffBuilder()
);
}
@@ -494,7 +421,6 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
otherValue,
baseStack,
otherStack,
customTesters,
j$.NullDiffBuilder()
);
if (!found && prevStackSize !== baseStack.length) {
@@ -559,9 +485,7 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
}
diffBuilder.withPath(key, function() {
if (
!self.eq_(a[key], b[key], aStack, bStack, customTesters, diffBuilder)
) {
if (!self.eq_(a[key], b[key], aStack, bStack, diffBuilder)) {
result = false;
}
});
@@ -673,9 +597,5 @@ getJasmineRequireObj().MatchersUtil = function(j$) {
return formatted;
}
function isDiffBuilder(obj) {
return obj && typeof obj.recordMismatch === 'function';
}
return MatchersUtil;
};

View File

@@ -50,40 +50,9 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
j$.Expectation = jRequire.Expectation(j$);
j$.buildExpectationResult = jRequire.buildExpectationResult(j$);
j$.JsApiReporter = jRequire.JsApiReporter(j$);
j$.asymmetricEqualityTesterArgCompatShim = jRequire.asymmetricEqualityTesterArgCompatShim(
j$
);
j$.makePrettyPrinter = jRequire.makePrettyPrinter(j$);
j$.basicPrettyPrinter_ = j$.makePrettyPrinter();
Object.defineProperty(j$, 'pp', {
get: function() {
j$.getEnv().deprecatedOnceWithStack(
'jasmine.pp is deprecated and will be removed in a future release. ' +
'Use the pp method of the matchersUtil passed to the matcher factory ' +
"or the asymmetric equality tester's `asymmetricMatch` method " +
'instead. See ' +
'<https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
return j$.basicPrettyPrinter_;
}
});
j$.MatchersUtil = jRequire.MatchersUtil(j$);
var staticMatchersUtil = new j$.MatchersUtil({
customTesters: [],
pp: j$.basicPrettyPrinter_
});
Object.defineProperty(j$, 'matchersUtil', {
get: function() {
j$.getEnv().deprecatedOnceWithStack(
'jasmine.matchersUtil is deprecated and will be removed ' +
'in a future release. Use the instance passed to the matcher factory or ' +
"the asymmetric equality tester's `asymmetricMatch` method instead. " +
'See <https://jasmine.github.io/tutorials/upgrading_to_4.0> for details.'
);
return staticMatchersUtil;
}
});
j$.ObjectContaining = jRequire.ObjectContaining(j$);
j$.ArrayContaining = jRequire.ArrayContaining(j$);
j$.ArrayWithExactContents = jRequire.ArrayWithExactContents(j$);