1'use strict';
2// Copy console accessor because requiring ../common touches it
3const consoleDescriptor = Object.getOwnPropertyDescriptor(global, 'console');
4Object.defineProperty(global, 'console', {
5  configurable: true,
6  writable: true,
7  value: {},
8});
9
10require('../../common');
11
12// This test checks that, if Node cannot put together the `console` object
13// because it is low on stack space while doing so, it can succeed later
14// once the stack has unwound a little, and `console` is in a usable state then.
15
16let compiledConsole;
17
18function a() {
19  try {
20    return a();
21  } catch (e) {
22    compiledConsole = consoleDescriptor.value;
23    if (compiledConsole.log) {
24      // Using `console.log` itself might not succeed yet, but the code for it
25      // has been compiled.
26    } else {
27      throw e;
28    }
29  }
30}
31
32a();
33
34compiledConsole.log('Hello, World!');
35