diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2018-10-01 09:41:37 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-01 12:41:37 -0400 |
commit | 3a6d4e62603a711a9ae3e0fa30fd4fd039169de1 (patch) | |
tree | 045a3bf984f9d3f38b02df2fd335b551939aa05f /js/console_test.ts | |
parent | 1fcc11a19d4522851870eec79ca17233a353cb9e (diff) |
Bind `this` to console methods (#873)
Fixes #872
Diffstat (limited to 'js/console_test.ts')
-rw-r--r-- | js/console_test.ts | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/js/console_test.ts b/js/console_test.ts index 9e6a37256..99a890e01 100644 --- a/js/console_test.ts +++ b/js/console_test.ts @@ -1,6 +1,6 @@ // Copyright 2018 the Deno authors. All rights reserved. MIT license. -import { test, assertEqual } from "./test_util.ts"; +import { test, assert, assertEqual } from "./test_util.ts"; import { stringifyArgs } from "./console.ts"; // tslint:disable-next-line:no-any @@ -88,7 +88,7 @@ test(function consoleTestStringifyCircular() { assertEqual(stringify(JSON), "{}"); assertEqual( stringify(console), - "Console { printFunc: [Function], debug: [Function: log], info: [Function: log], error: [Function: warn] }" + "Console { printFunc: [Function], log: [Function], debug: [Function], info: [Function], dir: [Function], warn: [Function], error: [Function], assert: [Function] }" ); }); @@ -122,3 +122,21 @@ test(function consoleTestError() { assertEqual(stringify(e).split("\n")[0], "MyError: This is an error"); } }); + +// Test bound this issue +test(function consoleDetachedLog() { + const log = console.log; + const dir = console.dir; + const debug = console.debug; + const info = console.info; + const warn = console.warn; + const error = console.error; + const consoleAssert = console.assert; + log("Hello world"); + dir("Hello world"); + debug("Hello world"); + info("Hello world"); + warn("Hello world"); + error("Hello world"); + consoleAssert(true); +}); |