Skip to content

Commit 263ae33

Browse files
committed
Merge pull request #109 from evanw/julien-f-fix-tests-node4
Fix tests for Node 4.
2 parents b2b029e + fe9d870 commit 263ae33

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

test.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ function compareStdout(done, sourceMap, source, expected) {
107107
'//@ sourceMappingURL=.generated.js.map');
108108
child_process.exec('node ./.generated', function(error, stdout, stderr) {
109109
try {
110-
compareLines((stdout + stderr).trim().split('\n'), expected);
110+
compareLines(
111+
(stdout + stderr)
112+
.trim()
113+
.split('\n')
114+
.filter(function (line) { return line !== '' }), // Empty lines are not relevant.
115+
expected
116+
);
111117
} catch (e) {
112118
return done(e);
113119
}
@@ -162,7 +168,10 @@ it('eval', function() {
162168
'eval("throw new Error(\'test\')");'
163169
], [
164170
'Error: test',
165-
/^ at Object\.eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
171+
172+
// Before Node 4, `Object.eval`, after just `eval`.
173+
/^ at (?:Object\.)?eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
174+
166175
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
167176
]);
168177
});
@@ -172,8 +181,8 @@ it('eval inside eval', function() {
172181
'eval("eval(\'throw new Error(\\"test\\")\')");'
173182
], [
174183
'Error: test',
175-
/^ at Object\.eval \(eval at <anonymous> \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
176-
/^ at Object\.eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
184+
/^ at (?:Object\.)?eval \(eval at <anonymous> \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
185+
/^ at (?:Object\.)?eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
177186
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
178187
]);
179188
});
@@ -197,7 +206,7 @@ it('eval with sourceURL', function() {
197206
'eval("throw new Error(\'test\')//@ sourceURL=sourceURL.js");'
198207
], [
199208
'Error: test',
200-
' at Object.eval (sourceURL.js:1:7)',
209+
/^ at (?:Object\.)?eval \(sourceURL\.js:1:7\)$/,
201210
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
202211
]);
203212
});
@@ -207,8 +216,8 @@ it('eval with sourceURL inside eval', function() {
207216
'eval("eval(\'throw new Error(\\"test\\")//@ sourceURL=sourceURL.js\')");'
208217
], [
209218
'Error: test',
210-
' at Object.eval (sourceURL.js:1:7)',
211-
/^ at Object\.eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
219+
/^ at (?:Object\.)?eval \(sourceURL\.js:1:7\)$/,
220+
/^ at (?:Object\.)?eval \(eval at <anonymous> \(.*\/line1\.js:1001:101\)/,
212221
/^ at Object\.exports\.test \(.*\/line1\.js:1001:101\)$/
213222
]);
214223
});
@@ -300,7 +309,11 @@ it('handleUncaughtExceptions is false', function(done) {
300309
], [
301310
/\/.generated.js:2$/,
302311
'function foo() { throw new Error("this is the error"); }',
303-
' ^',
312+
313+
// Before Node 4, the arrow points on the `new`, after on the
314+
// `throw`.
315+
/^ (?: )?\^$/,
316+
304317
'Error: this is the error',
305318
/^ at foo \(.*\/.original\.js:1:1\)$/
306319
]);
@@ -315,7 +328,7 @@ it('default options with empty source map', function(done) {
315328
], [
316329
/\/.generated.js:2$/,
317330
'function foo() { throw new Error("this is the error"); }',
318-
' ^',
331+
/^ (?: )?\^$/,
319332
'Error: this is the error',
320333
/^ at foo \(.*\/.generated.js:2:24\)$/
321334
]);
@@ -330,7 +343,7 @@ it('default options with source map with gap', function(done) {
330343
], [
331344
/\/.generated.js:2$/,
332345
'function foo() { throw new Error("this is the error"); }',
333-
' ^',
346+
/^ (?: )?\^$/,
334347
'Error: this is the error',
335348
/^ at foo \(.*\/.generated.js:2:24\)$/
336349
]);

0 commit comments

Comments
 (0)