mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-22 22:27:30 +08:00
Remove Set equal comparison
This commit is contained in:
@@ -48,11 +48,6 @@ describe("Entity initialization", () => {
|
|||||||
.which.is.an("array")
|
.which.is.an("array")
|
||||||
.and.is.deep.equal([400, 500, 600, 700, 800])
|
.and.is.deep.equal([400, 500, 600, 700, 800])
|
||||||
)
|
)
|
||||||
it("has someSet with numbers", () => expect(entity)
|
|
||||||
.to.have.property("someSet")
|
|
||||||
.which.is.instanceOf(Set)
|
|
||||||
.and.is.deep.equal(new Set([10, 20, 30, 40, 50, 60, 70]))
|
|
||||||
)
|
|
||||||
it("is equal to another empty SimpleEntity", () => expect(entity.equals(new SimpleEntity()))
|
it("is equal to another empty SimpleEntity", () => expect(entity.equals(new SimpleEntity()))
|
||||||
.to.be.true
|
.to.be.true
|
||||||
)
|
)
|
||||||
@@ -70,7 +65,6 @@ describe("Entity initialization", () => {
|
|||||||
someBoolean2: false,
|
someBoolean2: false,
|
||||||
someObjectString: new String("delta"),
|
someObjectString: new String("delta"),
|
||||||
someArray: [-1, -2, -3],
|
someArray: [-1, -2, -3],
|
||||||
someSet: new Set([-10, -20, -30]),
|
|
||||||
})
|
})
|
||||||
const other2 = new SimpleEntity({
|
const other2 = new SimpleEntity({
|
||||||
someNumber: 123,
|
someNumber: 123,
|
||||||
@@ -80,7 +74,6 @@ describe("Entity initialization", () => {
|
|||||||
someBoolean2: false,
|
someBoolean2: false,
|
||||||
someObjectString: "delta",
|
someObjectString: "delta",
|
||||||
someArray: [-1, -2, -3],
|
someArray: [-1, -2, -3],
|
||||||
someSet: new Set([-10, -20, -30]),
|
|
||||||
})
|
})
|
||||||
it("compares equal entities as equal", () => expect(other1.equals(other2))
|
it("compares equal entities as equal", () => expect(other1.equals(other2))
|
||||||
.to.be.true
|
.to.be.true
|
||||||
|
|||||||
@@ -69,34 +69,6 @@ describe("Utility class", () => {
|
|||||||
[-2, "Alpha", new String("beta"), new Number(40), [1, 2, 3]],
|
[-2, "Alpha", new String("beta"), new Number(40), [1, 2, 3]],
|
||||||
[new Number(-2), new String("alpha"), new String("beta"), new Number(40), new Array(1, 2, 3)]
|
[new Number(-2), new String("alpha"), new String("beta"), new Number(40), new Array(1, 2, 3)]
|
||||||
)).to.be.false // Second element is different
|
)).to.be.false // Second element is different
|
||||||
expect(Utility.equals(
|
|
||||||
new Set(["alpha", -67, new String("beta"), [1, 2, 3]]),
|
|
||||||
new Set([-67, "beta", new String("alpha"), [1, 2, 3]])
|
|
||||||
)).to.be.true
|
|
||||||
expect(Utility.equals( // First element has capital Beta
|
|
||||||
new Set(["alpha", -67, new String("Beta"), [1, 2, 3]]),
|
|
||||||
new Set([-67, "beta", new String("alpha"), [1, 2, 3]])
|
|
||||||
)).to.be.false
|
|
||||||
expect(Utility.equals( // First element has capital Beta
|
|
||||||
new Set(["alpha", -67, new String("beta"), [1, 2, 3]]),
|
|
||||||
new Set([-67, "beta", new String("alpha"), [1, 3]])
|
|
||||||
)).to.be.false
|
|
||||||
expect(Utility.equals( // Different number of elements
|
|
||||||
new Set([2, 4, 6, 8]),
|
|
||||||
new Set([8, 6, 4])
|
|
||||||
)).to.be.false
|
|
||||||
expect(Utility.equals( // Second element has different type
|
|
||||||
new Set([4, "6", 8]),
|
|
||||||
new Set([8, 6, 4])
|
|
||||||
)).to.be.false
|
|
||||||
expect(Utility.equals(
|
|
||||||
new Set([new IEntity({ a: "alpha", b: new String("beta") })]),
|
|
||||||
new Set([new IEntity({ a: "alpha", b: new String("beta") })]),
|
|
||||||
)).to.be.true
|
|
||||||
expect(Utility.equals( // First a key has a number
|
|
||||||
new Set([new IEntity({ a: 2, b: new String("beta") })]),
|
|
||||||
new Set([new IEntity({ a: "alpha", b: new String("beta") })]),
|
|
||||||
)).to.be.false
|
|
||||||
})
|
})
|
||||||
it("isValueOfType method test", () => {
|
it("isValueOfType method test", () => {
|
||||||
expect(Utility.isValueOfType(34, Number)).to.be.true
|
expect(Utility.isValueOfType(34, Number)).to.be.true
|
||||||
|
|||||||
@@ -175,14 +175,6 @@ export default class Utility {
|
|||||||
if (a instanceof Array && b instanceof Array) {
|
if (a instanceof Array && b instanceof Array) {
|
||||||
return a.length === b.length && a.every((value, i) => Utility.equals(value, b[i]))
|
return a.length === b.length && a.every((value, i) => Utility.equals(value, b[i]))
|
||||||
}
|
}
|
||||||
if (a instanceof Set && b instanceof Set) {
|
|
||||||
if (a.size !== b.size) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
a = [...a]
|
|
||||||
b = [...b]
|
|
||||||
return a.every(first => /** @type {Array} */(b).some(second => Utility.equals(first, second)))
|
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user