summaryrefslogtreecommitdiff
path: root/globals.ts
diff options
context:
space:
mode:
authorPig Fang <g-plane@hotmail.com>2018-06-05 15:58:50 +0800
committerRyan Dahl <ry@tinyclouds.org>2018-06-05 09:58:50 +0200
commit874db2a334eeaccd5f991e1e979073d75ba2932b (patch)
tree2391e4433984259eb8b16335201ddb2ef548c668 /globals.ts
parent71d789198bb07f78776aebee44c4c4be811650df (diff)
Add `console.assert` (#102)
Diffstat (limited to 'globals.ts')
-rw-r--r--globals.ts7
1 files changed, 7 insertions, 0 deletions
diff --git a/globals.ts b/globals.ts
index ed60bc46a..b8944b4be 100644
--- a/globals.ts
+++ b/globals.ts
@@ -32,6 +32,13 @@ _global["console"] = {
// tslint:disable-next-line:no-any
error(...args: any[]): void {
print("ERROR: " + stringifyArgs(args));
+ },
+
+ // tslint:disable-next-line:no-any
+ assert(condition: boolean, ...args: any[]): void {
+ if (!condition) {
+ throw new Error("Assertion failed: " + stringifyArgs(args));
+ }
}
};