Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add console.assert #102

Merged
merged 6 commits into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
print("Assertion failed: " + stringifyArgs(args));
}
}
};

Expand Down
2 changes: 2 additions & 0 deletions testdata/013_console_assert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
console.assert(true, "You can't see me.");
console.assert(false, "You will see me.");
1 change: 1 addition & 0 deletions testdata/013_console_assert.ts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
You will see me.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will be: "Assertion failed: You will see me. "

Copy link
Contributor

@qti3e qti3e Jun 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do:
../deno 013_console_assert.ts > 013_console_assert.ts.out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that is my fault. I will update.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g-plane No problem : )