-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
361 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { KeySetAll, KeySetAllExceptSome, KeySetNone, KeySetSome } from "../../../.."; | ||
|
||
const keySetAll = new KeySetAll<number>(); | ||
const keySetNone = new KeySetNone<number>(); | ||
|
||
const subSetKeys = [1, 2]; | ||
const restKeys = [3]; | ||
const keys = [...subSetKeys, ...restKeys]; | ||
const extraKeys = [4]; | ||
const moreKeys = [...keys, ...extraKeys]; | ||
const otherKeys = [5, 6]; | ||
|
||
const keySetSomeSameKeys = new KeySetSome(keys); | ||
const keySetSomeSubSetKeys = new KeySetSome(subSetKeys); | ||
const keySetSomeMoreKeys = new KeySetSome(moreKeys); | ||
const keySetSomeDiffKeys = new KeySetSome(otherKeys); | ||
|
||
const keySetAllExceptSomeSameKeys = new KeySetAllExceptSome(keys); | ||
const keySetAllExceptSomeSubSetKeys = new KeySetAllExceptSome(subSetKeys); | ||
const keySetAllExceptSomeMoreKeys = new KeySetAllExceptSome(moreKeys); | ||
const keySetAllExceptSomeDiffKeys = new KeySetAllExceptSome(otherKeys); | ||
|
||
const keySet = new KeySetAllExceptSome(keys); // => keys 1, 2, 3 | ||
|
||
// ALL | ||
|
||
test("#union(keySetAll)", () => { | ||
const rest = keySet.union(keySetAll); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
}); | ||
|
||
// NONE | ||
|
||
test("#union(keySetNone)", () => { | ||
const rest = keySet.union(keySetNone); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
expect(rest.keys).toEqual(keys); | ||
}); | ||
|
||
// SOME | ||
|
||
test("#union(keySetSomeSameKeys)", () => { | ||
const rest = keySet.union(keySetSomeSameKeys); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
}); | ||
|
||
test("#union(keySetSomeSubSetKeys)", () => { | ||
const rest = keySet.union(keySetSomeSubSetKeys); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
expect(rest.keys).toEqual(restKeys); | ||
}); | ||
|
||
test("#union(keySetSomeMoreKeys)", () => { | ||
const rest = keySet.union(keySetSomeMoreKeys); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
}); | ||
|
||
test("#union(keySetSomeDiffKeys)", () => { | ||
const rest = keySet.union(keySetSomeDiffKeys); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
expect(rest.keys).toEqual(keys); | ||
}); | ||
|
||
// ALL EXCEPT SOME | ||
|
||
test("#union(keySetAllExceptSomeSameKeys)", () => { | ||
const rest = keySet.union(keySetAllExceptSomeSameKeys); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
expect(keySet === rest).toBe(false); | ||
expect(rest.keys).toEqual(keys); | ||
}); | ||
|
||
test("#union(keySetAllExceptSomeSubSetKeys)", () => { | ||
const rest = keySet.union(keySetAllExceptSomeSubSetKeys); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
expect(keySet === rest).toBe(false); | ||
const r = rest as KeySetAllExceptSome<number>; | ||
expect(r.keys).toEqual(subSetKeys); | ||
}); | ||
|
||
test("#union(keySetAllExceptSomeMoreKeys)", () => { | ||
const rest = keySet.union(keySetAllExceptSomeMoreKeys); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
expect(keySet === rest).toBe(false); | ||
const r = rest as KeySetAllExceptSome<number>; | ||
expect(r.keys).toEqual(keys); | ||
}); | ||
|
||
test("#union(keySetAllExceptSomeDiffKeys)", () => { | ||
const rest = keySet.union(keySetAllExceptSomeDiffKeys); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { InvalidKeySetError, KeySetAll, KeySetAllExceptSome, KeySetNone, KeySetSome } from "../../../.."; | ||
|
||
const keySetAll = new KeySetAll(); | ||
const keySetNone = new KeySetNone(); | ||
const keySetSome = new KeySetSome([1, 2, 3]); | ||
const keySetAllExceptSome = new KeySetAllExceptSome([1, 2, 3]); | ||
|
||
const keySet = new KeySetAll(); | ||
|
||
test("#union(keySetAll)", () => { | ||
const rest = keySet.union(keySetAll); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
expect(keySet).not.toBe(rest); | ||
}); | ||
|
||
test("#union(keySetNone)", () => { | ||
const rest = keySet.union(keySetNone); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
expect(keySet).not.toBe(rest); | ||
}); | ||
|
||
test("#union(keySetSome)", () => { | ||
const rest = keySet.union(keySetSome); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
expect(keySet).not.toBe(rest); | ||
}); | ||
|
||
test("#union(keySetAllExceptSome)", () => { | ||
const rest = keySet.union(keySetAllExceptSome); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
expect(keySet).not.toBe(rest); | ||
}); | ||
|
||
test("#union(somethingInvalid)", () => { | ||
expect(() => { | ||
keySet.union((null as unknown) as KeySetAll); | ||
}).toThrowError(InvalidKeySetError); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { InvalidKeySetError, KeySetAll, KeySetAllExceptSome, KeySetNone, KeySetSome } from "../../../.."; | ||
|
||
const keySetAll = new KeySetAll(); | ||
const keySetNone = new KeySetNone(); | ||
const keySetSome = new KeySetSome([1, 2, 3]); | ||
const keySetAllExceptSome = new KeySetAllExceptSome([1, 2, 3]); | ||
|
||
const keySet = new KeySetNone(); | ||
|
||
test("#union(keySetAll)", () => { | ||
const rest = keySet.union(keySetAll); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
expect(keySet).not.toBe(rest); | ||
}); | ||
|
||
test("#union(keySetNone)", () => { | ||
const rest = keySet.union(keySetNone); | ||
expect(rest instanceof KeySetNone).toBeTruthy(); | ||
expect(keySet).not.toBe(rest); | ||
}); | ||
|
||
test("#union(keySetSome)", () => { | ||
const rest = keySet.union(keySetSome); | ||
expect(rest instanceof KeySetSome).toBeTruthy(); | ||
|
||
const r = rest as KeySetSome<number>; | ||
expect(r.keys).toEqual(keySetSome.keys); | ||
}); | ||
|
||
test("#union(keySetAllExceptSome)", () => { | ||
const rest = keySet.union(keySetAllExceptSome); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
|
||
const r = rest as KeySetAllExceptSome<number>; | ||
expect(r.keys).toEqual(keySetAllExceptSome.keys); | ||
}); | ||
|
||
test("#union(somethingInvalid)", () => { | ||
expect(() => { | ||
keySet.union((null as unknown) as KeySetAll); | ||
}).toThrowError(InvalidKeySetError); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import { KeySetAll, KeySetAllExceptSome, KeySetNone, KeySetSome } from "../../../.."; | ||
|
||
const keySetAll = new KeySetAll<number>(); | ||
const keySetNone = new KeySetNone<number>(); | ||
|
||
const subSetKeys = [1, 2]; | ||
const restKeys = [3]; | ||
const keys = [...subSetKeys, ...restKeys]; | ||
const extraKeys = [4]; | ||
const moreKeys = [...keys, ...extraKeys]; | ||
const otherKeys = [5, 6]; | ||
|
||
const keySetSomeSameKeys = new KeySetSome(keys); | ||
const keySetSomeSubSetKeys = new KeySetSome(subSetKeys); | ||
const keySetSomeMoreKeys = new KeySetSome(moreKeys); | ||
const keySetSomeDiffKeys = new KeySetSome(otherKeys); | ||
|
||
const keySetAllExceptSomeSameKeys = new KeySetAllExceptSome(keys); | ||
const keySetAllExceptSomeSubSetKeys = new KeySetAllExceptSome(subSetKeys); | ||
const keySetAllExceptSomeMoreKeys = new KeySetAllExceptSome(moreKeys); | ||
const keySetAllExceptSomeDiffKeys = new KeySetAllExceptSome(otherKeys); | ||
|
||
const keySet = new KeySetSome(keys); // => keys 1, 2, 3 | ||
|
||
// ALL | ||
|
||
test("#union(keySetAll)", () => { | ||
const rest = keySet.union(keySetAll); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
}); | ||
|
||
// NONE | ||
|
||
test("#union(keySetNone)", () => { | ||
const rest = keySet.union(keySetNone); | ||
expect(rest instanceof KeySetSome).toBeTruthy(); | ||
expect(rest.keys).toEqual(keySet.keys); | ||
}); | ||
|
||
// SOME | ||
|
||
test("#union(keySetSomeSameKeys)", () => { | ||
const rest = keySet.union(keySetSomeSameKeys); | ||
expect(rest instanceof KeySetSome).toBeTruthy(); | ||
expect(keySet === rest).toBe(false); | ||
const r = rest as KeySetSome<number>; | ||
expect(r.keys).toEqual(keySet.keys); | ||
}); | ||
|
||
test("#union(keySetSomeSubSetKeys)", () => { | ||
const rest = keySet.union(keySetSomeSubSetKeys); | ||
expect(rest instanceof KeySetSome).toBeTruthy(); | ||
expect(keySet === rest).toBe(false); | ||
const r = rest as KeySetSome<number>; | ||
expect(r.keys).toEqual(keySet.keys); | ||
}); | ||
|
||
test("#union(keySetSomeMoreKeys)", () => { | ||
const rest = keySet.union(keySetSomeMoreKeys); | ||
expect(rest instanceof KeySetSome).toBeTruthy(); | ||
expect(keySet === rest).toBe(false); | ||
const r = rest as KeySetSome<number>; | ||
expect(r.keys).toEqual(moreKeys); | ||
}); | ||
|
||
test("#union(keySetSomeDiffKeys)", () => { | ||
const rest = keySet.union(keySetSomeDiffKeys); | ||
expect(rest instanceof KeySetSome).toBeTruthy(); | ||
expect(keySet === rest).toBe(false); | ||
const r = rest as KeySetSome<number>; | ||
expect(r.keys).toEqual([...keys, ...otherKeys].sort()); | ||
}); | ||
|
||
// ALL EXCEPT SOME | ||
|
||
test("#union(keySetAllExceptSomeSameKeys)", () => { | ||
const rest = keySet.union(keySetAllExceptSomeSameKeys); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
}); | ||
|
||
test("#union(keySetAllExceptSomeSubSetKeys)", () => { | ||
const rest = keySet.union(keySetAllExceptSomeSubSetKeys); | ||
expect(rest instanceof KeySetAll).toBeTruthy(); | ||
}); | ||
|
||
test("#union(keySetAllExceptSomeMoreKeys)", () => { | ||
const rest = keySet.union(keySetAllExceptSomeMoreKeys); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
const r = rest as KeySetAllExceptSome<number>; | ||
expect(r.keys).toEqual(extraKeys); | ||
}); | ||
|
||
test("#union(keySetAllExceptSomeDiffKeys)", () => { | ||
const rest = keySet.union(keySetAllExceptSomeDiffKeys); | ||
expect(rest instanceof KeySetAllExceptSome).toBeTruthy(); | ||
const r = rest as KeySetAllExceptSome<number>; | ||
expect(r.keys).toEqual(otherKeys); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.