forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompilerCore.ts
More file actions
33 lines (33 loc) · 2.07 KB
/
compilerCore.ts
File metadata and controls
33 lines (33 loc) · 2.07 KB
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
namespace ts {
describe("unittests:: compilerCore", () => {
describe("equalOwnProperties", () => {
it("correctly equates objects", () => {
assert.isTrue(equalOwnProperties({}, {}));
assert.isTrue(equalOwnProperties({ a: 1 }, { a: 1 }));
assert.isTrue(equalOwnProperties({ a: 1, b: 2 }, { b: 2, a: 1 }));
});
it("correctly identifies unmatched objects", () => {
assert.isFalse(equalOwnProperties({}, { a: 1 }), "missing left property");
assert.isFalse(equalOwnProperties({ a: 1 }, {}), "missing right property");
assert.isFalse(equalOwnProperties({ a: 1 }, { a: 2 }), "differing property");
});
it("correctly identifies undefined vs hasOwnProperty", () => {
assert.isFalse(equalOwnProperties({}, { a: undefined }), "missing left property");
assert.isFalse(equalOwnProperties({ a: undefined }, {}), "missing right property");
});
it("truthiness", () => {
const trythyTest = (l: any, r: any) => !!l === !!r;
assert.isFalse(equalOwnProperties({}, { a: 1 }, trythyTest), "missing left truthy property");
assert.isFalse(equalOwnProperties({}, { a: 0 }, trythyTest), "missing left falsey property");
assert.isFalse(equalOwnProperties({ a: 1 }, {}, trythyTest), "missing right truthy property");
assert.isFalse(equalOwnProperties({ a: 0 }, {}, trythyTest), "missing right falsey property");
assert.isTrue(equalOwnProperties({ a: 1 }, { a: "foo" }, trythyTest), "valid equality");
});
it("all equal", () => {
assert.isFalse(equalOwnProperties({}, { a: 1 }, () => true), "missing left property");
assert.isFalse(equalOwnProperties({ a: 1 }, {}, () => true), "missing right property");
assert.isTrue(equalOwnProperties({ a: 1 }, { a: 2 }, () => true), "valid equality");
});
});
});
}