From 3a6d4e62603a711a9ae3e0fa30fd4fd039169de1 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Mon, 1 Oct 2018 09:41:37 -0700 Subject: Bind `this` to console methods (#873) Fixes #872 --- js/console_test.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'js/console_test.ts') 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); +}); -- cgit v1.2.3