summaryrefslogtreecommitdiff
path: root/test/message/stdin_messages.js
blob: 6e1ced4124f2a6423ca10ef013ddb6babf08c234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';

require('../common');

var spawn = require('child_process').spawn;

function run(cmd, strict, cb) {
  var args = [];
  if (strict) args.push('--use_strict');
  args.push('-p');
  var child = spawn(process.execPath, args);
  child.stdout.pipe(process.stdout);
  child.stderr.pipe(process.stdout);
  child.stdin.end(cmd);
  child.on('close', cb);
}

var queue =
  [ 'with(this){__filename}',
    '42',
    'throw new Error("hello")',
    'var x = 100; y = x;',
    'var ______________________________________________; throw 10' ];

function go() {
  var c = queue.shift();
  if (!c) return console.log('done');
  run(c, false, function() {
    run(c, true, go);
  });
}

go();