diff options
author | Bradley Farias <bradley.meck@gmail.com> | 2017-12-22 11:19:50 -0600 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-02-10 14:19:54 +0100 |
commit | de848ac1e0483327a2ce8716c3f8567eaeacb660 (patch) | |
tree | 5395e33d22cd318f618b24752e178f68f40e851f /test/parallel/test-repl-underscore.js | |
parent | 6007a9cc0e361d428123e4c0f74024c6cd7815f4 (diff) | |
download | android-node-v8-de848ac1e0483327a2ce8716c3f8567eaeacb660.tar.gz android-node-v8-de848ac1e0483327a2ce8716c3f8567eaeacb660.tar.bz2 android-node-v8-de848ac1e0483327a2ce8716c3f8567eaeacb660.zip |
repl: refactor tests to not rely on timing
Tests relying on synchronous timing have been migrated to use events.
PR-URL: https://github.com/nodejs/node/pull/17828
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'test/parallel/test-repl-underscore.js')
-rw-r--r-- | test/parallel/test-repl-underscore.js | 124 |
1 files changed, 67 insertions, 57 deletions
diff --git a/test/parallel/test-repl-underscore.js b/test/parallel/test-repl-underscore.js index 91f32223e1..1b22dcc722 100644 --- a/test/parallel/test-repl-underscore.js +++ b/test/parallel/test-repl-underscore.js @@ -28,20 +28,22 @@ function testSloppyMode() { _; // remains 30 from user input `); - assertOutput(r.output, [ - 'undefined', - 'undefined', - 'undefined', - '10', - '10', - 'Expression assignment to _ now disabled.', - '20', - '20', - '30', - '30', - '40', - '30' - ]); + r.on('exit', () => { + assertOutput(r.output, [ + 'undefined', + 'undefined', + 'undefined', + '10', + '10', + 'Expression assignment to _ now disabled.', + '20', + '20', + '30', + '30', + '40', + '30' + ]); + }); } function testStrictMode() { @@ -61,20 +63,22 @@ function testStrictMode() { _; // remains 30 from user input `); - assertOutput(r.output, [ - 'undefined', - 'undefined', - 'undefined', - 'undefined', - '20', - '30', - '30', - 'undefined', - '30', - 'undefined', - 'undefined', - '30' - ]); + r.on('exit', () => { + assertOutput(r.output, [ + 'undefined', + 'undefined', + 'undefined', + 'undefined', + '20', + '30', + '30', + 'undefined', + '30', + 'undefined', + 'undefined', + '30' + ]); + }); } function testMagicMode() { @@ -94,20 +98,22 @@ function testMagicMode() { _; // remains 30 from user input `); - assertOutput(r.output, [ - 'undefined', - '10', - '10', - 'undefined', - '20', - '30', - '30', - 'undefined', - '30', - 'undefined', - '50', - '30' - ]); + r.on('exit', () => { + assertOutput(r.output, [ + 'undefined', + '10', + '10', + 'undefined', + '20', + '30', + '30', + 'undefined', + '30', + 'undefined', + '50', + '30' + ]); + }); } function testResetContext() { @@ -121,15 +127,17 @@ function testResetContext() { _; // expect 20 `); - assertOutput(r.output, [ - 'Expression assignment to _ now disabled.', - '10', - '10', - 'Clearing context...', - '10', - '20', - '20' - ]); + r.on('exit', () => { + assertOutput(r.output, [ + 'Expression assignment to _ now disabled.', + '10', + '10', + 'Clearing context...', + '10', + '20', + '20' + ]); + }); } function testResetContextGlobal() { @@ -141,12 +149,14 @@ function testResetContextGlobal() { _; // remains 10 `); - assertOutput(r.output, [ - 'Expression assignment to _ now disabled.', - '10', - '10', - '10', - ]); + r.on('exit', () => { + assertOutput(r.output, [ + 'Expression assignment to _ now disabled.', + '10', + '10', + '10', + ]); + }); // delete globals leaked by REPL when `useGlobal` is `true` delete global.module; |