| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -322,12 +322,12 @@ function REPLServer(prompt, | |||
| 322 | 322 | let awaitPromise = false; | |
| 323 | 323 | const input = code; | |
| 324 | 324 | ||
| 325 | - if (/^\s*{/.test(code) && /}\s*$/.test(code)) { | ||
| 326 | - // It's confusing for `{ a : 1 }` to be interpreted as a block | ||
| 327 | - // statement rather than an object literal. So, we first try | ||
| 328 | - // to wrap it in parentheses, so that it will be interpreted as | ||
| 329 | - // an expression. Note that if the above condition changes, | ||
| 330 | - // lib/internal/repl/utils.js needs to be changed to match. | ||
| 325 | + // It's confusing for `{ a : 1 }` to be interpreted as a block | ||
| 326 | + // statement rather than an object literal. So, we first try | ||
| 327 | + // to wrap it in parentheses, so that it will be interpreted as | ||
| 328 | + // an expression. Note that if the above condition changes, | ||
| 329 | + // lib/internal/repl/utils.js needs to be changed to match. | ||
| 330 | + if (/^\s*{/.test(code) && !/;\s*$/.test(code)) { | ||
| 331 | 331 | code = `(${code.trim()})\n`; | |
| 332 | 332 | wrappedCmd = true; | |
| 333 | 333 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,6 +88,23 @@ async function tests(options) { | |||
| 88 | 88 | '\x1B[36m[Function: koo]\x1B[39m', | |
| 89 | 89 | '\x1B[1G\x1B[0Jrepl > \x1B[8G'], | |
| 90 | 90 | ['a', [1, 2], undefined], | |
| 91 | + [" { b: 1 }['b'] === 1", [2, 6], '\x1B[33mtrue\x1B[39m', | ||
| 92 | + " { b: 1 }['b']", | ||
| 93 | + '\x1B[90m1\x1B[39m\x1B[22G\x1B[1A\x1B[1B\x1B[2K\x1B[1A ', | ||
| 94 | + '\x1B[90m1\x1B[39m\x1B[23G\x1B[1A\x1B[1B\x1B[2K\x1B[1A=== 1', | ||
| 95 | + '\x1B[90mtrue\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r', | ||
| 96 | + '\x1B[33mtrue\x1B[39m', | ||
| 97 | + '\x1B[1G\x1B[0Jrepl > \x1B[8G' | ||
| 98 | + ], | ||
| 99 | + ["{ b: 1 }['b'] === 1;", [2, 7], '\x1B[33mfalse\x1B[39m', | ||
| 100 | + "{ b: 1 }['b']", | ||
| 101 | + '\x1B[90m1\x1B[39m\x1B[21G\x1B[1A\x1B[1B\x1B[2K\x1B[1A ', | ||
| 102 | + '\x1B[90m1\x1B[39m\x1B[22G\x1B[1A\x1B[1B\x1B[2K\x1B[1A=== 1', | ||
| 103 | + '\x1B[90mtrue\x1B[39m\x1B[27G\x1B[1A\x1B[1B\x1B[2K\x1B[1A;', | ||
| 104 | + '\x1B[90mfalse\x1B[39m\x1B[28G\x1B[1A\x1B[1B\x1B[2K\x1B[1A\r', | ||
| 105 | + '\x1B[33mfalse\x1B[39m', | ||
| 106 | + '\x1B[1G\x1B[0Jrepl > \x1B[8G' | ||
| 107 | + ], | ||
| 91 | 108 | ['{ a: true }', [2, 3], '{ a: \x1B[33mtrue\x1B[39m }', | |
| 92 | 109 | '{ a: tru\x1B[90me\x1B[39m\x1B[16G\x1B[0Ke }\r', | |
| 93 | 110 | '{ a: \x1B[33mtrue\x1B[39m }', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments