aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-repl.js
AgeCommit message (Collapse)Author
2016-08-13repl,util: insert carriage returns in outputJungMinu
`\n` is not enough for Linux with some custom stream add carriage returns to ensure that the output is displayed correctly using `\r\n` should not be a problem, even on non-Windows platforms. Fixes: https://github.com/nodejs/node/issues/7954 PR-URL: https://github.com/nodejs/node/pull/8028 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-07-27repl: Use displayErrors for SyntaxErrorPrince J Wesley
```js node 🙈 ₹ git:(upstream ⚡ display-error-repl) ./node > var 4; var 4; ^ SyntaxError: Unexpected number > ``` PR-URL: https://github.com/nodejs/node/pull/7589 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
2016-07-15repl: Mitigate vm #548 function redefinition issuePrince J Wesley
```js node 🙈 ₹ git:(upstream ⚡ repl-tmp-548) ./node > function name() { return "node"; }; undefined > name() 'node' > function name() { return "nodejs"; }; undefined > name() 'nodejs' > ``` Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Lance Ball <lball@redhat.com>
2016-06-29test: fix tests after V8 upgradeAli Ijaz Sheikh
* Changes to messages. * V8 enabled proxy support by default. The --harmony_proxies flag is now gone. PR-URL: https://github.com/nodejs/node/pull/6482 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2016-06-10test: use random ports where possibleBrian White
This helps to prevent issues where a failed test can keep a bound socket open long enough to cause other tests to fail with EADDRINUSE because the same port number is used. PR-URL: https://github.com/nodejs/node/pull/7045 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
2016-06-04repl: refine handling of illegal tokensRich Trott
Illegal tokens are only recoverable in string literals, RegExp literals, and block comments. If not in one of these constructs, immediately return an error rather than giving the user false hope by giving them a chance to try to recover. PR-URL: https://github.com/nodejs/node/pull/7104 Fixes: https://github.com/nodejs/node/issues/3611 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-04-14test: update error message for JSON.parseMichaël Zasso
V8 5.0 introduced a small modification for the unexpected end of input error. PR-URL: https://github.com/nodejs/node/pull/5945 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com>
2016-04-04test: explicitly set global in test-replRich Trott
The test intentionally assigns a global. Use `global` namespace to make it clear that it is intentional and not an accidental leak. PR-URL: https://github.com/nodejs/node/pull/6026 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2016-03-30test: fix flaky test-replBrian White
PR-URL: https://github.com/nodejs/node/pull/5914 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-03-18repl: support standalone blocksPrince J Wesley
Enable support for standalone block statements. ```js node 🙈 ₹ git:(upstream ⚡ bare-block) ./node > { var x = 3; console.log(x); } 3 undefined > {} {} > { x:1, y:"why not", z: function() {} } { x: 1, y: 'why not', z: [Function] } > ``` For the ambiguous inputs like `{ x }`, the existing REPL behaviour (ES6 literal shorthand) is preserved (prefers expression over statement). Fixes: https://github.com/nodejs/node/issues/5576 PR-URL: https://github.com/nodejs/node/pull/5581 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
2016-02-29repl: fix stack trace column number in strict modePrince J Wesley
On strict mode, "'use strict'; void 0; " is added as prefix in order to prevent "use strict" as the result value for let/const statements. It causes wrong column number in stack trace. PR-URL: https://github.com/nodejs/node/pull/5416 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
2016-02-16repl: allow multiline function callZirak
Currently, the repl allows multiline function declarations, strings, and all sorts of niceties by catching the SyntaxErrors they issue and ignoring them. However, the SyntaxError raised by multiline function calls was not caught. This commit adds to the whitelist. PR-URL: https://github.com/nodejs/node/pull/3823 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-02-09repl: handle quotes within regexp literalPrince J Wesley
PR-URL: https://github.com/nodejs/node/pull/5117 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
2016-01-13test: fix style issues after eslint updateMichaël Zasso
Replace var keyword with const or let. PR-URL: https://github.com/nodejs/io.js/pull/2286 Reviewed-By: Roman Reiss <me@silverwind.io>
2015-12-01repl: allow leading period in multiline inputZirak
When writing multiline input, one can't chain function calls as if the lines begin with a period, since those are treated as REPL commands. Before: > ([0, 1, 2] ... .map(x => x + 1)) Invalid REPL keyword After: > ([0, 1, 2] ... .map(x => x + 1)) [ 1, 2, 3 ] PR-URL: https://github.com/nodejs/node/pull/3835 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-11-30module,repl: remove repl require() hackBen Noordhuis
Remove a hack that was introduced in commit bb6d468d from November 2010. This is groundwork for a follow-up commit that makes it possible to use internal modules in lib/repl.js. PR-URL: https://github.com/nodejs/node/pull/4026 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-10-28repl: handle comments properlySakthipriyan Vairamani
As it is, the comments are not handled properly in REPL. So, if the comments have `'` or `"`, then they are treated as incomplete string literals and the error is thrown in REPL. This patch refactors the existing logic and groups everything in a class. Fixes: https://github.com/nodejs/node/issues/3421 PR-URL: https://github.com/nodejs/node/pull/3515 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-10-16test: apply correct assert.fail() argumentsRich Trott
The assert.fail function signature has the message as the third argument but, understandably, it is often assumed that it is the first argument (or at least the first argument if no other arguments are passed). This corrects the assert.fail() invocations in the Node.js tests. Before: assert.fail('message'); // result: AssertionError: 'message' undefined undefined After: assert.fail(null, null, 'message'); // result: AssertionError: message PR-URL: https://github.com/nodejs/node/pull/3378 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2015-10-14test: fix tests after V8 upgradeMichaël Zasso
Some error messages have changed and the --debugger flag does not exist in V8 anymore. PR-URL: https://github.com/nodejs/node/pull/3351 Reviewed-By: indutny - Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
2015-10-08test: refresh temp directory when using pipeRich Trott
common.PIPE resides in the temp directory (except on Windows). Insure that the temp directory is refreshed in tests that use common.PIPE. PR-URL: https://github.com/nodejs/node/pull/3231 Fixes: https://github.com/nodejs/node/issues/3227 Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2015-09-22repl: backslash bug fixSakthipriyan Vairamani
The actual problem was with the line parsing logic for string literals. When we use backslash in the string literals, it used to remember the `\` as the previous character even after we parsed the character next to it. This leads to REPL thinking that the end of string literals is not reached. This patch replaces the previous character with `null`, so that it will properly skip the character next to it. Previous Discussion: https://github.com/nodejs/node/pull/2952 Fixes: https://github.com/nodejs/node/issues/2749 PR-URL: https://github.com/nodejs/node/pull/2968 Reviewed-By: Roman Reiss <me@silverwind.io>
2015-08-23node: rename from io.js to nodecjihrig
This commit replaces instances of io.js with Node.js, based on the recent convergence. There are some remaining instances of io.js, related to build and the installer. Fixes: https://github.com/nodejs/node/issues/2361 PR-URL: https://github.com/nodejs/node/pull/2367 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: João Reis <reis@janeasystems.com>
2015-08-04repl: don't clobber RegExp.$ propertiesSakthipriyan Vairamani
In REPL, if we evaluate the `RegExp` object's predefined properties, and if they happen to have the same expression, for example, > RegExp.$1 'RegExp.$1' then doing `eval(RegExp.$1)` would evaluate `RegExp.$1` recursively and eventually throw `RangeError: Maximum call stack size exceeded`. This patch stores the old values of `RegExp`'s predefined proprties in an array and restores them just before the current expression entered by user is evaluated. Fixes: https://github.com/nodejs/io.js/issues/597 PR-URL: https://github.com/nodejs/io.js/pull/2137 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-07-25repl: better empty line handlingSakthipriyan Vairamani
In REPL, if we try to evaluate an empty line, we get `undefined`. > process.version 'v2.3.4' > undefined > undefined > This patch prevents `undefined` from printing if the string is empty. > process.version 'v2.3.5-pre' > > > PR-URL: https://github.com/nodejs/io.js/pull/2163 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-07-25repl: improving line continuation handlingSakthipriyan Vairamani
As it is, REPL doesn't honour the line continuation feature very well. This patch 1. keeps track of the beginning of the string literals and if they don't end or current line doesn't end with line continuation, then error out. 2. monitors if the line continuation character is used without the string literal and errors out if that happens. PR-URL: https://github.com/nodejs/io.js/pull/2163 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-07-25repl: preventing REPL crash with inherited propertiesSakthipriyan Vairamani
When an inherited property is used as a REPL keyword, the REPL crashes. ➜ Desktop iojs > process.version 'v2.3.4' > .toString readline.js:913 stream[ESCAPE_DECODER].next(r[i]); ^ TypeError: Cannot read property 'call' of undefined at REPLServer.parseREPLKeyword (repl.js:746:15) at REPLServer.<anonymous> (repl.js:284:16) at emitOne (events.js:77:13) at REPLServer.emit (events.js:169:7) at REPLServer.Interface._onLine (readline.js:210:10) at REPLServer.Interface._line (readline.js:549:8) at REPLServer.Interface._ttyWrite (readline.js:826:14) at ReadStream.onkeypress (readline.js:105:10) at emitTwo (events.js:87:13) at ReadStream.emit (events.js:172:7) ➜ Desktop This patch makes the internal `commands` object inherit from `null` so that there will be no inherited properties. > process.version 'v2.3.5-pre' > .toString Invalid REPL keyword > PR-URL: https://github.com/nodejs/io.js/pull/2163 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-07-25repl: fixing `undefined` in invalid REPL keyword errorSakthipriyan Vairamani
When an invalid REPL keyword is used, we actually print `undefined` as well in the console. > process.version 'v2.3.4' > .invalid_repl_command Invalid REPL keyword undefined > This patch prevents printing `undefined` in this case. > process.version 'v2.3.5-pre' > .invalid_repl_command Invalid REPL keyword > PR-URL: https://github.com/nodejs/io.js/pull/2163 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2015-05-19test: enable linting for testsRoman Reiss
Enable linting for the test directory. A number of changes was made so all tests conform the current rules used by lib and src directories. The only exception for tests is that unreachable (dead) code is allowed. test-fs-non-number-arguments-throw had to be excluded from the changes because of a weird issue on Windows CI. PR-URL: https://github.com/nodejs/io.js/pull/1721 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-04-28deps: upgrade v8 to 4.2.77.13Ben Noordhuis
This commit applies some secondary changes in order to make `make test` pass cleanly: * disable broken postmortem debugging in common.gypi * drop obsolete strict mode test in parallel/test-repl * drop obsolete test parallel/test-v8-features PR-URL: https://github.com/iojs/io.js/pull/1232 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2015-01-19repl: make REPL support multiline template literalsXiaowei Li
Let REPL enter multiline mode if user's input contains unterminated template literals. PR-URL: https://github.com/iojs/io.js/pull/333 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-01-12Remove excessive copyright/license boilerplateisaacs
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
2015-01-07test: fix parallel/test-repl with new v8Ben Noordhuis
Per the ES6 spec, V8 3.31 no longer throws a SyntaxError for scoped function declarations. PR-URL: https://github.com/iojs/io.js/pull/243 Reviewed-By: Domenic Denicola <domenic@domenicdenicola.com> Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2014-12-17test: split test in parallel/sequentialFedor Indutny
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: https://github.com/iojs/io.js/pull/172 Fix: iojs/io.js#139