diff options
author | Prince J Wesley <princejohnwesley@gmail.com> | 2016-07-09 04:29:23 +0530 |
---|---|---|
committer | Lance Ball <lball@redhat.com> | 2016-07-15 13:44:34 -0400 |
commit | bb9eabec40ed95e0193d08bf3f9b16d774904a17 (patch) | |
tree | be691be6503e52d4105949e42ce2aad612dbc217 /test/known_issues | |
parent | 5aac4c42da104c30d8f701f1042d61c2f06b7e6c (diff) | |
download | android-node-v8-bb9eabec40ed95e0193d08bf3f9b16d774904a17.tar.gz android-node-v8-bb9eabec40ed95e0193d08bf3f9b16d774904a17.tar.bz2 android-node-v8-bb9eabec40ed95e0193d08bf3f9b16d774904a17.zip |
repl: Mitigate vm #548 function redefinition issue
```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>
Diffstat (limited to 'test/known_issues')
-rw-r--r-- | test/known_issues/test-repl-function-redefinition-edge-case.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/known_issues/test-repl-function-redefinition-edge-case.js b/test/known_issues/test-repl-function-redefinition-edge-case.js new file mode 100644 index 0000000000..03b721fba7 --- /dev/null +++ b/test/known_issues/test-repl-function-redefinition-edge-case.js @@ -0,0 +1,38 @@ +// Reference: https://github.com/nodejs/node/pull/7624 +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const repl = require('repl'); +const stream = require('stream'); + +common.globalCheck = false; + +const r = initRepl(); + +r.input.emit('data', 'function a() { return 42; } (1)\n'); +r.input.emit('data', 'a\n'); +r.input.emit('data', '.exit'); + +const expected = '1\n[Function a]\n'; +const got = r.output.accumulator.join(''); +assert.strictEqual(got, expected); + +function initRepl() { + const input = new stream(); + input.write = input.pause = input.resume = () => {}; + input.readable = true; + + const output = new stream(); + output.writable = true; + output.accumulator = []; + + output.write = (data) => output.accumulator.push(data); + + return repl.start({ + input, + output, + useColors: false, + terminal: false, + prompt: '' + }); +} |