|
1 | 1 | 'use strict';
|
2 |
| -var assert = require('assert'), |
3 |
| - child_process = require('child_process'), |
4 |
| - spawn = child_process.spawn, |
5 |
| - fork = child_process.fork, |
6 |
| - execFile = child_process.execFile, |
7 |
| - windows = (process.platform === 'win32'), |
8 |
| - cmd = (windows) ? 'rundll32' : 'ls', |
9 |
| - invalidcmd = 'hopefully_you_dont_have_this_on_your_machine', |
10 |
| - invalidArgsMsg = /Incorrect value of args option/, |
11 |
| - invalidOptionsMsg = /options argument must be an object/, |
12 |
| - empty = require('../common').fixturesDir + '/empty.js', |
13 |
| - errors = 0; |
14 |
| - |
15 |
| -try { |
16 |
| - // Ensure this throws a TypeError |
17 |
| - var child = spawn(invalidcmd, 'this is not an array'); |
18 |
| - |
19 |
| - child.on('error', function(err) { |
20 |
| - errors++; |
21 |
| - }); |
| 2 | +const assert = require('assert'); |
| 3 | +const child_process = require('child_process'); |
| 4 | +const spawn = child_process.spawn; |
| 5 | +const fork = child_process.fork; |
| 6 | +const execFile = child_process.execFile; |
| 7 | +const common = require('../common'); |
| 8 | +const cmd = common.isWindows ? 'rundll32' : 'ls'; |
| 9 | +const invalidcmd = 'hopefully_you_dont_have_this_on_your_machine'; |
| 10 | +const invalidArgsMsg = /Incorrect value of args option/; |
| 11 | +const invalidOptionsMsg = /options argument must be an object/; |
| 12 | +const empty = common.fixturesDir + '/empty.js'; |
22 | 13 |
|
23 |
| -} catch (e) { |
24 |
| - assert.equal(e instanceof TypeError, true); |
25 |
| -} |
| 14 | +assert.throws(function() { |
| 15 | + var child = spawn(invalidcmd, 'this is not an array'); |
| 16 | + child.on('error', assert.fail); |
| 17 | +}, TypeError); |
26 | 18 |
|
27 | 19 | // verify that valid argument combinations do not throw
|
28 | 20 | assert.doesNotThrow(function() {
|
@@ -62,17 +54,13 @@ assert.throws(function() {
|
62 | 54 | spawn(cmd, [], 1);
|
63 | 55 | }, invalidOptionsMsg);
|
64 | 56 |
|
65 |
| -process.on('exit', function() { |
66 |
| - assert.equal(errors, 0); |
67 |
| -}); |
68 |
| - |
69 | 57 | // Argument types for combinatorics
|
70 |
| -var a = [], |
71 |
| - o = {}, |
72 |
| - c = (function callback() {}), |
73 |
| - s = 'string', |
74 |
| - u = undefined, |
75 |
| - n = null; |
| 58 | +const a = []; |
| 59 | +const o = {}; |
| 60 | +const c = function callback() {}; |
| 61 | +const s = 'string'; |
| 62 | +const u = undefined; |
| 63 | +const n = null; |
76 | 64 |
|
77 | 65 | // function spawn(file=f [,args=a] [, options=o]) has valid combinations:
|
78 | 66 | // (f)
|
|
0 commit comments