-
Notifications
You must be signed in to change notification settings - Fork 30k
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
console,test: make message test more accurate #14580
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,17 +6,26 @@ global.console = {}; | |
|
||
require('../common'); | ||
|
||
// This test checks that, if Node cannot put together the `console` object | ||
// because it is low on stack space while doing so, it can succeed later | ||
// once the stack has unwound a little, and `console` is in a usable state then. | ||
|
||
let compiledConsole; | ||
|
||
function a() { | ||
try { | ||
return a(); | ||
} catch (e) { | ||
const console = consoleDescriptor.get(); | ||
if (console.log) { | ||
console.log('Hello, World!'); | ||
compiledConsole = consoleDescriptor.get(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a check that |
||
if (compiledConsole.log) { | ||
// Using `console.log` itself might not succeed yet, but the code for it | ||
// has been compiled. | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove this branch? if (!compiledConsole.log) {
throw e;
} If you think it's clearer as is, no problem, ignore the comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for pointing it out, but yes, I think it’s clearer this way. |
||
throw e; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO you should throw a new Error, one that explicitly represents the failure to compile (could be prepared in advance if there's no room on the stack). |
||
} | ||
} | ||
} | ||
|
||
a(); | ||
|
||
compiledConsole.log('Hello, World!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: swallowing