xref: /third_party/node/test/parallel/test-console-assign-undefined.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ci// Patch global.console before importing modules that may modify the console
41cb0ef41Sopenharmony_ci// object.
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst tmp = global.console;
71cb0ef41Sopenharmony_ciglobal.console = 42;
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cirequire('../common');
101cb0ef41Sopenharmony_ciconst assert = require('assert');
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci// Originally the console had a getter. Test twice to verify it had no side
131cb0ef41Sopenharmony_ci// effect.
141cb0ef41Sopenharmony_ciassert.strictEqual(global.console, 42);
151cb0ef41Sopenharmony_ciassert.strictEqual(global.console, 42);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciassert.throws(
181cb0ef41Sopenharmony_ci  () => console.log('foo'),
191cb0ef41Sopenharmony_ci  { name: 'TypeError' }
201cb0ef41Sopenharmony_ci);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciglobal.console = 1;
231cb0ef41Sopenharmony_ciassert.strictEqual(global.console, 1);
241cb0ef41Sopenharmony_ciassert.strictEqual(console, 1);
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci// Reset the console
271cb0ef41Sopenharmony_ciglobal.console = tmp;
281cb0ef41Sopenharmony_ciconsole.log('foo');
29

Indexes created Thu Nov 07 10:32:03 CST 2024