diff options
author | Veetaha <[email protected]> | 2020-02-28 22:26:22 +0000 |
---|---|---|
committer | Veetaha <[email protected]> | 2020-02-28 22:26:22 +0000 |
commit | 3ad0574d7e3f1af1e28f7f5cbc085faa30759e47 (patch) | |
tree | de0192925c1b4bcdad592401771fe4344b11a3e7 /editors/code/src/util.ts | |
parent | 9cf25770542dfbf35c710f7c214f65ecaad39100 (diff) |
vscode: add equality assertion
Diffstat (limited to 'editors/code/src/util.ts')
-rw-r--r-- | editors/code/src/util.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 733bdc8c5..5a5f11a10 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts | |||
@@ -11,6 +11,16 @@ export function assert(condition: unknown, explanation: string): asserts conditi | |||
11 | } | 11 | } |
12 | } | 12 | } |
13 | 13 | ||
14 | assert.eq = <T>(bibba: unknown, bobba: T, explanation: string): asserts bibba is T => { | ||
15 | try { | ||
16 | nativeAssert.strictEqual(bibba, bobba, explanation); | ||
17 | } catch (err) { | ||
18 | log.error(`Equality assertion failed:`, explanation); | ||
19 | throw err; | ||
20 | } | ||
21 | } | ||
22 | |||
23 | |||
14 | export const log = { | 24 | export const log = { |
15 | enabled: true, | 25 | enabled: true, |
16 | debug(message?: any, ...optionalParams: any[]): void { | 26 | debug(message?: any, ...optionalParams: any[]): void { |