|  | 
|  | 1 | +// Copyright Joyent, Inc. and other Node contributors. | 
|  | 2 | +// | 
|  | 3 | +// Permission is hereby granted, free of charge, to any person obtaining a | 
|  | 4 | +// copy of this software and associated documentation files (the | 
|  | 5 | +// "Software"), to deal in the Software without restriction, including | 
|  | 6 | +// without limitation the rights to use, copy, modify, merge, publish, | 
|  | 7 | +// distribute, sublicense, and/or sell copies of the Software, and to permit | 
|  | 8 | +// persons to whom the Software is furnished to do so, subject to the | 
|  | 9 | +// following conditions: | 
|  | 10 | +// | 
|  | 11 | +// The above copyright notice and this permission notice shall be included | 
|  | 12 | +// in all copies or substantial portions of the Software. | 
|  | 13 | +// | 
|  | 14 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | 
|  | 15 | +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 
|  | 16 | +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | 
|  | 17 | +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | 
|  | 18 | +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | 
|  | 19 | +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | 
|  | 20 | +// USE OR OTHER DEALINGS IN THE SOFTWARE. | 
|  | 21 | + | 
|  | 22 | +/* | 
|  | 23 | + * This is a regression test for https://github.com/joyent/node/issues/8874. | 
|  | 24 | + */ | 
|  | 25 | +var common = require('../common'); | 
|  | 26 | +var assert = require('assert'); | 
|  | 27 | + | 
|  | 28 | +var spawn = require('child_process').spawn; | 
|  | 29 | +// use -i to force node into interactive mode, despite stdout not being a TTY | 
|  | 30 | +var args = [ '-i' ]; | 
|  | 31 | +var child = spawn(process.execPath, args); | 
|  | 32 | + | 
|  | 33 | +var input = 'var foo = "bar\\\nbaz"'; | 
|  | 34 | +// Match '...' as well since it marks a multi-line statement | 
|  | 35 | +var expectOut = /^> ... undefined\n/; | 
|  | 36 | + | 
|  | 37 | +child.stderr.setEncoding('utf8'); | 
|  | 38 | +child.stderr.on('data', function(c) { | 
|  | 39 | +  throw new Error('child.stderr be silent'); | 
|  | 40 | +}); | 
|  | 41 | + | 
|  | 42 | +child.stdout.setEncoding('utf8'); | 
|  | 43 | +var out = ''; | 
|  | 44 | +child.stdout.on('data', function(c) { | 
|  | 45 | +  out += c; | 
|  | 46 | +}); | 
|  | 47 | + | 
|  | 48 | +child.stdout.on('end', function() { | 
|  | 49 | +  assert(expectOut.test(out)); | 
|  | 50 | +  console.log('ok'); | 
|  | 51 | +}); | 
|  | 52 | + | 
|  | 53 | +child.stdin.end(input); | 
0 commit comments