summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormonkingxue <yingchenxue@qq.com>2018-05-09 10:34:57 +0800
committerRuben Bridgewater <ruben@bridgewater.de>2018-05-18 15:47:17 +0200
commit9aa4ec43fce7fd9166459c98f347760cf450a350 (patch)
tree87550905478fcf01db756bd04ede6c8b8ab2baab /test
parent9deca876bb94626564184ad263ff80dc8042808b (diff)
downloadandroid-node-v8-9aa4ec43fce7fd9166459c98f347760cf450a350.tar.gz
android-node-v8-9aa4ec43fce7fd9166459c98f347760cf450a350.tar.bz2
android-node-v8-9aa4ec43fce7fd9166459c98f347760cf450a350.zip
repl: add friendly tips about how to exit repl
Imitate python repl, when the user enters 'exit' or 'quit', no longer prompt 'Reference Error', but prompts 'To exit, press ^D or type .exit'. If the user defines variables named 'exit' or 'quit' , only the value of the variables are output PR-URL: https://github.com/nodejs/node/pull/20617 Fixes: https://github.com/nodejs/node/issues/19021 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-repl.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js
index e14398541d..b9c92c3cd6 100644
--- a/test/parallel/test-repl.js
+++ b/test/parallel/test-repl.js
@@ -132,6 +132,29 @@ const strictModeTests = [
}
];
+const friendlyExitTests = [
+ {
+ send: 'exit',
+ expect: '(To exit, press ^D or type .exit)'
+ },
+ {
+ send: 'quit',
+ expect: '(To exit, press ^D or type .exit)'
+ },
+ {
+ send: 'quit = 1',
+ expect: '1'
+ },
+ {
+ send: 'quit',
+ expect: '1'
+ },
+ {
+ send: 'exit',
+ expect: '(To exit, press ^D or type .exit)'
+ },
+];
+
const errorTests = [
// Uncaught error throws and prints out
{
@@ -742,6 +765,7 @@ const tcpTests = [
const [ socket, replServer ] = await startUnixRepl();
await runReplTests(socket, prompt_unix, unixTests);
+ await runReplTests(socket, prompt_unix, friendlyExitTests);
await runReplTests(socket, prompt_unix, errorTests);
replServer.replMode = repl.REPL_MODE_STRICT;
await runReplTests(socket, prompt_unix, strictModeTests);