The previous Map equality code was assuming that the set of keys would be identical between the two Maps. This change adds insertion-order tracking for each key with its corresponding key. If one of the two keys is an asymmetric equality obj, the keys are eq()'d, and if it succeeds, the corresponding values are compared. Otherwise, the "main" key is looked up directly in the other object; this is to prevent similar-looking obj keys with different obj identities from comparing equal. Fixes #1432.
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
describe("Anything", function() {
|
|
it("matches a string", function() {
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.asymmetricMatch('foo')).toBe(true);
|
|
});
|
|
|
|
it("matches a number", function() {
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.asymmetricMatch(42)).toBe(true);
|
|
});
|
|
|
|
it("matches an object", function() {
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.asymmetricMatch({ foo: 'bar' })).toBe(true);
|
|
});
|
|
|
|
it("matches an array", function() {
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.asymmetricMatch([1,2,3])).toBe(true);
|
|
});
|
|
|
|
it("matches a Map", function() {
|
|
jasmine.getEnv().requireFunctioningMaps();
|
|
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.asymmetricMatch(new Map())).toBe(true);
|
|
});
|
|
|
|
it("matches a Set", function() {
|
|
jasmine.getEnv().requireFunctioningSets();
|
|
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.asymmetricMatch(new Set())).toBe(true);
|
|
});
|
|
|
|
it("doesn't match undefined", function() {
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.asymmetricMatch()).toBe(false);
|
|
expect(anything.asymmetricMatch(undefined)).toBe(false);
|
|
});
|
|
|
|
it("doesn't match null", function() {
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.asymmetricMatch(null)).toBe(false);
|
|
});
|
|
|
|
it("jasmineToString's itself", function() {
|
|
var anything = new jasmineUnderTest.Anything();
|
|
|
|
expect(anything.jasmineToString()).toEqual("<jasmine.anything>");
|
|
});
|
|
});
|