[Pkg-javascript-commits] [node-stack-utils] 39/67: Make tests pass on latest Node.js

Bastien Roucariès rouca at moszumanska.debian.org
Thu Sep 7 09:53:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-stack-utils.

commit c735f3cb3ffd44018c7838bf14349fe0b4145140
Author: isaacs <i at izs.me>
Date:   Wed Feb 1 22:17:41 2017 -0800

    Make tests pass on latest Node.js
    
    Removes linting and replaces indentation with spaces, more common in
    Node-land.
    
    Uses node-tap for tests because I couldn't figure out how to make the
    ava tests pass properly.  Upgrades nested-error-stacks to handle changes
    to the Error.prototype.stack property descriptor.
    
    Temporarily turned off appveyor and travis, because the async function
    test *only* passes in node-master, not in 4 or 6.
---
 .travis.yml               |   9 -
 appveyor.yml              |  21 --
 index.js                  | 484 +++++++++++++--------------
 package.json              |   9 +-
 test/_utils.js            |   7 +-
 test/long-stack-traces.js | 214 ++++++------
 test/test.js              | 820 ++++++++++++++++++++++++----------------------
 7 files changed, 778 insertions(+), 786 deletions(-)

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index c25e769..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-language: node_js
-node_js:
-  - '5'
-  - '4'
-  - '0.12'
-  - '0.10'
-
-after_script:
-  - 'cat ./coverage/lcov.info | ./node_modules/.bin/coveralls'
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 597071b..0000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-environment:
-  matrix:
-    - nodejs_version: '5'
-    - nodejs_version: '4'
-    - nodejs_version: '0.12'
-install:
-  - ps: Install-Product node $env:nodejs_version
-  - set CI=true
-  - npm -g install npm at latest || (timeout 30 && npm -g install npm at latest)
-  - set PATH=%APPDATA%\npm;%PATH%
-  - npm install || (timeout 30 && npm install)
-matrix:
-  fast_finish: true
-build: off
-version: '{build}'
-shallow_clone: true
-clone_depth: 1
-test_script:
-  - node --version
-  - npm --version
-  - npm run test-win || (timeout 30 && npm run test-win)
diff --git a/index.js b/index.js
index ed4fa0b..214e2e0 100644
--- a/index.js
+++ b/index.js
@@ -1,289 +1,289 @@
 module.exports = StackUtils;
 
 function StackUtils(opts) {
-	if (!(this instanceof StackUtils)) {
-		throw new Error('StackUtils constructor must be called with new');
-	}
-	opts = opts || {};
-	this._cwd = (opts.cwd || process.cwd()).replace(/\\/g, '/');
-	this._internals = opts.internals || [];
-	this._wrapCallSite = opts.wrapCallSite || false;
+  if (!(this instanceof StackUtils)) {
+    throw new Error('StackUtils constructor must be called with new');
+  }
+  opts = opts || {};
+  this._cwd = (opts.cwd || process.cwd()).replace(/\\/g, '/');
+  this._internals = opts.internals || [];
+  this._wrapCallSite = opts.wrapCallSite || false;
 }
 
 module.exports.nodeInternals = nodeInternals;
 
 function nodeInternals() {
-	if (!module.exports.natives) {
-		module.exports.natives = Object.keys(process.binding('natives'));
-		module.exports.natives.push('bootstrap_node', 'node');
-	}
-
-	return module.exports.natives.map(function (n) {
-		return new RegExp('\\(' + n + '\\.js:\\d+:\\d+\\)$');
-	}).concat([
-		/\s*at (bootstrap_)?node\.js:\d+:\d+?$/,
-		/\/\.node-spawn-wrap-\w+-\w+\/node:\d+:\d+\)?$/
-	]);
+  if (!module.exports.natives) {
+    module.exports.natives = Object.keys(process.binding('natives'));
+    module.exports.natives.push('bootstrap_node', 'node');
+  }
+
+  return module.exports.natives.map(function (n) {
+    return new RegExp('\\(' + n + '\\.js:\\d+:\\d+\\)$');
+  }).concat([
+    /\s*at (bootstrap_)?node\.js:\d+:\d+?$/,
+    /\/\.node-spawn-wrap-\w+-\w+\/node:\d+:\d+\)?$/
+  ]);
 }
 
 StackUtils.prototype.clean = function (stack) {
-	if (!Array.isArray(stack)) {
-		stack = stack.split('\n');
-	}
-
-	if (!(/^\s*at /.test(stack[0])) &&
-		(/^\s*at /.test(stack[1]))) {
-		stack = stack.slice(1);
-	}
-
-	var outdent = false;
-	var lastNonAtLine = null;
-	var result = [];
-
-	stack.forEach(function (st) {
-		st = st.replace(/\\/g, '/');
-		var isInternal = this._internals.some(function (internal) {
-			return internal.test(st);
-		});
-
-		if (isInternal) {
-			return null;
-		}
-
-		var isAtLine = /^\s*at /.test(st);
-
-		if (outdent) {
-			st = st.replace(/\s+$/, '').replace(/^(\s+)at /, '$1');
-		} else {
-			st = st.trim();
-			if (isAtLine) {
-				st = st.substring(3);
-			}
-		}
-
-		st = st.replace(this._cwd + '/', '');
-
-		if (st) {
-			if (isAtLine) {
-				if (lastNonAtLine) {
-					result.push(lastNonAtLine);
-					lastNonAtLine = null;
-				}
-				result.push(st);
-			} else {
-				outdent = true;
-				lastNonAtLine = st;
-			}
-		}
-	}, this);
-
-	stack = result.join('\n').trim();
-
-	if (stack) {
-		return stack + '\n';
-	}
-	return '';
+  if (!Array.isArray(stack)) {
+    stack = stack.split('\n');
+  }
+
+  if (!(/^\s*at /.test(stack[0])) &&
+    (/^\s*at /.test(stack[1]))) {
+    stack = stack.slice(1);
+  }
+
+  var outdent = false;
+  var lastNonAtLine = null;
+  var result = [];
+
+  stack.forEach(function (st) {
+    st = st.replace(/\\/g, '/');
+    var isInternal = this._internals.some(function (internal) {
+      return internal.test(st);
+    });
+
+    if (isInternal) {
+      return null;
+    }
+
+    var isAtLine = /^\s*at /.test(st);
+
+    if (outdent) {
+      st = st.replace(/\s+$/, '').replace(/^(\s+)at /, '$1');
+    } else {
+      st = st.trim();
+      if (isAtLine) {
+        st = st.substring(3);
+      }
+    }
+
+    st = st.replace(this._cwd + '/', '');
+
+    if (st) {
+      if (isAtLine) {
+        if (lastNonAtLine) {
+          result.push(lastNonAtLine);
+          lastNonAtLine = null;
+        }
+        result.push(st);
+      } else {
+        outdent = true;
+        lastNonAtLine = st;
+      }
+    }
+  }, this);
+
+  stack = result.join('\n').trim();
+
+  if (stack) {
+    return stack + '\n';
+  }
+  return '';
 };
 
 StackUtils.prototype.captureString = function (limit, fn) {
-	if (typeof limit === 'function') {
-		fn = limit;
-		limit = Infinity;
-	}
-	if (!fn) {
-		fn = this.captureString;
-	}
-
-	var limitBefore = Error.stackTraceLimit;
-	if (limit) {
-		Error.stackTraceLimit = limit;
-	}
-
-	var obj = {};
-
-	Error.captureStackTrace(obj, fn);
-	var stack = obj.stack;
-	Error.stackTraceLimit = limitBefore;
-
-	return this.clean(stack);
+  if (typeof limit === 'function') {
+    fn = limit;
+    limit = Infinity;
+  }
+  if (!fn) {
+    fn = this.captureString;
+  }
+
+  var limitBefore = Error.stackTraceLimit;
+  if (limit) {
+    Error.stackTraceLimit = limit;
+  }
+
+  var obj = {};
+
+  Error.captureStackTrace(obj, fn);
+  var stack = obj.stack;
+  Error.stackTraceLimit = limitBefore;
+
+  return this.clean(stack);
 };
 
 StackUtils.prototype.capture = function (limit, fn) {
-	if (typeof limit === 'function') {
-		fn = limit;
-		limit = Infinity;
-	}
-	if (!fn) {
-		fn = this.capture;
-	}
-	var prepBefore = Error.prepareStackTrace;
-	var limitBefore = Error.stackTraceLimit;
-	var wrapCallSite = this._wrapCallSite;
-
-	Error.prepareStackTrace = function (obj, site) {
-		if (wrapCallSite) {
-			return site.map(wrapCallSite);
-		}
-		return site;
-	};
-
-	if (limit) {
-		Error.stackTraceLimit = limit;
-	}
-
-	var obj = {};
-	Error.captureStackTrace(obj, fn);
-	var stack = obj.stack;
-	Error.prepareStackTrace = prepBefore;
-	Error.stackTraceLimit = limitBefore;
-
-	return stack;
+  if (typeof limit === 'function') {
+    fn = limit;
+    limit = Infinity;
+  }
+  if (!fn) {
+    fn = this.capture;
+  }
+  var prepBefore = Error.prepareStackTrace;
+  var limitBefore = Error.stackTraceLimit;
+  var wrapCallSite = this._wrapCallSite;
+
+  Error.prepareStackTrace = function (obj, site) {
+    if (wrapCallSite) {
+      return site.map(wrapCallSite);
+    }
+    return site;
+  };
+
+  if (limit) {
+    Error.stackTraceLimit = limit;
+  }
+
+  var obj = {};
+  Error.captureStackTrace(obj, fn);
+  var stack = obj.stack;
+  Error.prepareStackTrace = prepBefore;
+  Error.stackTraceLimit = limitBefore;
+
+  return stack;
 };
 
 StackUtils.prototype.at = function at(fn) {
-	if (!fn) {
-		fn = at;
-	}
+  if (!fn) {
+    fn = at;
+  }
 
-	var site = this.capture(1, fn)[0];
+  var site = this.capture(1, fn)[0];
 
-	if (!site) {
-		return {};
-	}
+  if (!site) {
+    return {};
+  }
 
-	var res = {
-		line: site.getLineNumber(),
-		column: site.getColumnNumber()
-	};
+  var res = {
+    line: site.getLineNumber(),
+    column: site.getColumnNumber()
+  };
 
-	this._setFile(res, site.getFileName());
+  this._setFile(res, site.getFileName());
 
-	if (site.isConstructor()) {
-		res.constructor = true;
-	}
+  if (site.isConstructor()) {
+    res.constructor = true;
+  }
 
-	if (site.isEval()) {
-		res.evalOrigin = site.getEvalOrigin();
-	}
+  if (site.isEval()) {
+    res.evalOrigin = site.getEvalOrigin();
+  }
 
-	if (site.isNative()) {
-		res.native = true;
-	}
+  if (site.isNative()) {
+    res.native = true;
+  }
 
-	var typename = null;
-	try {
-		typename = site.getTypeName();
-	} catch (er) {}
+  var typename = null;
+  try {
+    typename = site.getTypeName();
+  } catch (er) {}
 
-	if (typename &&
-		typename !== 'Object' &&
-		typename !== '[object Object]') {
-		res.type = typename;
-	}
+  if (typename &&
+    typename !== 'Object' &&
+    typename !== '[object Object]') {
+    res.type = typename;
+  }
 
-	var fname = site.getFunctionName();
-	if (fname) {
-		res.function = fname;
-	}
+  var fname = site.getFunctionName();
+  if (fname) {
+    res.function = fname;
+  }
 
-	var meth = site.getMethodName();
-	if (meth && fname !== meth) {
-		res.method = meth;
-	}
+  var meth = site.getMethodName();
+  if (meth && fname !== meth) {
+    res.method = meth;
+  }
 
-	return res;
+  return res;
 };
 
 StackUtils.prototype._setFile = function (result, filename) {
-	if (filename) {
-		filename = filename.replace(/\\/g, '/');
-		if ((filename.indexOf(this._cwd + '/') === 0)) {
-			filename = filename.substr(this._cwd.length + 1);
-		}
-		result.file = filename;
-	}
+  if (filename) {
+    filename = filename.replace(/\\/g, '/');
+    if ((filename.indexOf(this._cwd + '/') === 0)) {
+      filename = filename.substr(this._cwd.length + 1);
+    }
+    result.file = filename;
+  }
 };
 
 var re = new RegExp(
-	'^' +
-		// Sometimes we strip out the '    at' because it's noisy
-	'(?:\\s*at )?' +
-		// $1 = ctor if 'new'
-	'(?:(new) )?' +
-		// Object.method [as foo] (, maybe
-		// $2 = function name
-		// $3 = method name
-	'(?:([^\\(\\[]*)(?: \\[as ([^\\]]+)\\])? \\()?' +
-		// (eval at <anonymous> (file.js:1:1),
-		// $4 = eval origin
-		// $5:$6:$7 are eval file/line/col, but not normally reported
-	'(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?' +
-		// file:line:col
-		// $8:$9:$10
-		// $11 = 'native' if native
-	'(?:(.+?):(\\d+):(\\d+)|(native))' +
-		// maybe close the paren, then end
-	'\\)?$'
+  '^' +
+    // Sometimes we strip out the '    at' because it's noisy
+  '(?:\\s*at )?' +
+    // $1 = ctor if 'new'
+  '(?:(new) )?' +
+    // Object.method [as foo] (, maybe
+    // $2 = function name
+    // $3 = method name
+  '(?:([^\\(\\[]*)(?: \\[as ([^\\]]+)\\])? \\()?' +
+    // (eval at <anonymous> (file.js:1:1),
+    // $4 = eval origin
+    // $5:$6:$7 are eval file/line/col, but not normally reported
+  '(?:eval at ([^ ]+) \\((.+?):(\\d+):(\\d+)\\), )?' +
+    // file:line:col
+    // $8:$9:$10
+    // $11 = 'native' if native
+  '(?:(.+?):(\\d+):(\\d+)|(native))' +
+    // maybe close the paren, then end
+  '\\)?$'
 );
 
 StackUtils.prototype.parseLine = function parseLine(line) {
-	var match = line && line.match(re);
-	if (!match) {
-		return null;
-	}
-
-	var ctor = match[1] === 'new';
-	var fname = match[2];
-	var meth = match[3];
-	var evalOrigin = match[4];
-	var evalFile = match[5];
-	var evalLine = Number(match[6]);
-	var evalCol = Number(match[7]);
-	var file = match[8];
-	var lnum = match[9];
-	var col = match[10];
-	var native = match[11] === 'native';
-
-	var res = {};
-
-	if (lnum) {
-		res.line = Number(lnum);
-	}
-
-	if (col) {
-		res.column = Number(col);
-	}
-
-	this._setFile(res, file);
-
-	if (ctor) {
-		res.constructor = true;
-	}
-
-	if (evalOrigin) {
-		res.evalOrigin = evalOrigin;
-		res.evalLine = evalLine;
-		res.evalColumn = evalCol;
-		res.evalFile = evalFile && evalFile.replace(/\\/g, '/');
-	}
-
-	if (native) {
-		res.native = true;
-	}
-
-	if (fname) {
-		res.function = fname;
-	}
-
-	if (meth && fname !== meth) {
-		res.method = meth;
-	}
-
-	return res;
+  var match = line && line.match(re);
+  if (!match) {
+    return null;
+  }
+
+  var ctor = match[1] === 'new';
+  var fname = match[2];
+  var meth = match[3];
+  var evalOrigin = match[4];
+  var evalFile = match[5];
+  var evalLine = Number(match[6]);
+  var evalCol = Number(match[7]);
+  var file = match[8];
+  var lnum = match[9];
+  var col = match[10];
+  var native = match[11] === 'native';
+
+  var res = {};
+
+  if (lnum) {
+    res.line = Number(lnum);
+  }
+
+  if (col) {
+    res.column = Number(col);
+  }
+
+  this._setFile(res, file);
+
+  if (ctor) {
+    res.constructor = true;
+  }
+
+  if (evalOrigin) {
+    res.evalOrigin = evalOrigin;
+    res.evalLine = evalLine;
+    res.evalColumn = evalCol;
+    res.evalFile = evalFile && evalFile.replace(/\\/g, '/');
+  }
+
+  if (native) {
+    res.native = true;
+  }
+
+  if (fname) {
+    res.function = fname;
+  }
+
+  if (meth && fname !== meth) {
+    res.method = meth;
+  }
+
+  return res;
 };
 
 var bound = new StackUtils();
 
 Object.keys(StackUtils.prototype).forEach(function (key) {
-	StackUtils[key] = bound[key].bind(bound);
+  StackUtils[key] = bound[key].bind(bound);
 });
diff --git a/package.json b/package.json
index 862a76c..ec1ccbc 100644
--- a/package.json
+++ b/package.json
@@ -13,8 +13,7 @@
     "node": ">=0.10.0"
   },
   "scripts": {
-    "test": "xo && nyc --reporter lcov --reporter text --cache ava --verbose",
-    "test-win": "ava --verbose"
+    "test": "tap test/*.js --cov"
   },
   "files": [
     "index.js"
@@ -24,14 +23,12 @@
   ],
   "dependencies": {},
   "devDependencies": {
-    "ava": "^0.8.0",
     "bluebird": "^3.1.1",
     "coveralls": "^2.11.6",
     "flatten": "0.0.1",
-    "nested-error-stacks": "^1.0.2",
-    "nyc": "^5.2.0",
+    "nested-error-stacks": "^2.0.0",
     "pify": "^2.3.0",
     "q": "^1.4.1",
-    "xo": "^0.12.1"
+    "tap": "^10.0.0"
   }
 }
diff --git a/test/_utils.js b/test/_utils.js
index e9e3ff7..b80c7e7 100644
--- a/test/_utils.js
+++ b/test/_utils.js
@@ -5,6 +5,9 @@ module.exports.join = join;
 module.exports.fixtureDir = path.join(__dirname, 'fixtures');
 
 function join() {
-	var args = Array.prototype.slice.call(arguments);
-	return flatten(args).join('\n') + '\n';
+  var args = Array.prototype.slice.call(arguments);
+  return flatten(args).join('\n') + '\n';
 }
+
+if (module === require.main)
+  require('tap').pass('this is fine')
diff --git a/test/long-stack-traces.js b/test/long-stack-traces.js
index 293dded..c77d6da 100644
--- a/test/long-stack-traces.js
+++ b/test/long-stack-traces.js
@@ -1,134 +1,134 @@
-import test from 'ava';
-import StackUtils from '../';
-import longStackTraces from './fixtures/long-stack-traces';
-import pify from 'pify';
+const t = require('tap');
+const StackUtils = require('../');
+const longStackTraces = require('./fixtures/long-stack-traces');
+const pify = require('pify');
 const nestedErrors = pify(require('./fixtures/nested-errors'), Promise);
 
-import {join, fixtureDir} from './_utils';
+const {join, fixtureDir} = require('./_utils');
 
 function internals() {
-	return StackUtils.nodeInternals().concat([
-		/\/long-stack-traces\.js:\d+:\d+\)?$/,
-		/\/internal-error\.js:\d+:\d+\)?$/,
-		/\/internal-then\.js:\d+:\d+\)?$/,
-		/\/node_modules\//
-	]);
+  return StackUtils.nodeInternals().concat([
+    /\/long-stack-traces\.js:\d+:\d+\)?$/,
+    /\/internal-error\.js:\d+:\d+\)?$/,
+    /\/internal-then\.js:\d+:\d+\)?$/,
+    /\/node_modules\//
+  ]);
 }
 
 const stackUtils = new StackUtils({internals: internals(), cwd: fixtureDir});
 
-test('indents lines after first "From previous event:"', async t => {
-	const cleanedStack = stackUtils.clean(await longStackTraces.bluebird);
-	const expected = join([
-		'mostInner (produce-long-stack-traces.js:10:5)',
-		'From previous event:',
-		'    evenMoreInner (produce-long-stack-traces.js:9:29)',
-		'From previous event:',
-		'    inner (produce-long-stack-traces.js:8:28)',
-		'From previous event:',
-		'    outer (produce-long-stack-traces.js:7:27)',
-		'From previous event:',
-		'    Object.<anonymous> (produce-long-stack-traces.js:6:36)'
-	]);
-
-	t.is(cleanedStack, expected);
+t.test('indents lines after first "From previous event:"', async t => {
+  const cleanedStack = stackUtils.clean(await longStackTraces.bluebird);
+  const expected = join([
+    'mostInner (produce-long-stack-traces.js:10:5)',
+    'From previous event:',
+    '    evenMoreInner (produce-long-stack-traces.js:9:29)',
+    'From previous event:',
+    '    inner (produce-long-stack-traces.js:8:28)',
+    'From previous event:',
+    '    outer (produce-long-stack-traces.js:7:27)',
+    'From previous event:',
+    '    Object.<anonymous> (produce-long-stack-traces.js:6:36)'
+  ]);
+
+  t.is(cleanedStack, expected);
 });
 
-test('removes empty "From previous event:" sections from the bottom', async t => {
-	const stack = await longStackTraces.bluebird.bottom;
-	const cleanedStack = stackUtils.clean(stack);
-
-	const expected = join([
-		'mostInner (produce-long-stack-traces.js:43:6)',
-		'From previous event:',
-		'    evenMoreInner (produce-long-stack-traces.js:42:30)',
-		'From previous event:',
-		'    inner (produce-long-stack-traces.js:41:29)',
-		'From previous event:',
-		'    outer (produce-long-stack-traces.js:40:28)'
-	]);
-
-	t.is(cleanedStack, expected);
+t.test('removes empty "From previous event:" sections from the bottom', async t => {
+  const stack = await longStackTraces.bluebird.bottom;
+  const cleanedStack = stackUtils.clean(stack);
+
+  const expected = join([
+    'mostInner (produce-long-stack-traces.js:43:6)',
+    'From previous event:',
+    '    evenMoreInner (produce-long-stack-traces.js:42:30)',
+    'From previous event:',
+    '    inner (produce-long-stack-traces.js:41:29)',
+    'From previous event:',
+    '    outer (produce-long-stack-traces.js:40:28)'
+  ]);
+
+  t.is(cleanedStack, expected);
 });
 
-test('removes empty "From previous event:" sections from the top', async t => {
-	const stack = await longStackTraces.bluebird.top;
-	const cleanedStack = stackUtils.clean(stack);
-
-	const expected = join([
-		'From previous event:',
-		'    evenMoreInner (produce-long-stack-traces.js:33:29)',
-		'From previous event:',
-		'    inner (produce-long-stack-traces.js:32:28)',
-		'From previous event:',
-		'    outer (produce-long-stack-traces.js:31:27)',
-		'From previous event:',
-		'    Object.<anonymous> (produce-long-stack-traces.js:30:40)'
-	]);
-
-	t.is(cleanedStack, expected);
+t.test('removes empty "From previous event:" sections from the top', async t => {
+  const stack = await longStackTraces.bluebird.top;
+  const cleanedStack = stackUtils.clean(stack);
+
+  const expected = join([
+    'From previous event:',
+    '    evenMoreInner (produce-long-stack-traces.js:33:29)',
+    'From previous event:',
+    '    inner (produce-long-stack-traces.js:32:28)',
+    'From previous event:',
+    '    outer (produce-long-stack-traces.js:31:27)',
+    'From previous event:',
+    '    Object.<anonymous> (produce-long-stack-traces.js:30:40)'
+  ]);
+
+  t.is(cleanedStack, expected);
 });
 
-test('removes empty "From previous event:" sections from the middle', async t => {
-	const stack = await longStackTraces.bluebird.middle;
-	const cleanedStack = stackUtils.clean(stack);
-
-	const expected = join([
-		'mostInner (produce-long-stack-traces.js:22:5)',
-		'From previous event:',
-		'    evenMoreInner (produce-long-stack-traces.js:21:29)',
-		'From previous event:',
-		'    inner (produce-long-stack-traces.js:20:10)',
-		'From previous event:',
-		'    outer (produce-long-stack-traces.js:19:27)',
-		'From previous event:',
-		'    Object.<anonymous> (produce-long-stack-traces.js:18:43)'
-	]);
-
-	t.is(cleanedStack, expected);
+t.test('removes empty "From previous event:" sections from the middle', async t => {
+  const stack = await longStackTraces.bluebird.middle;
+  const cleanedStack = stackUtils.clean(stack);
+
+  const expected = join([
+    'mostInner (produce-long-stack-traces.js:22:5)',
+    'From previous event:',
+    '    evenMoreInner (produce-long-stack-traces.js:21:29)',
+    'From previous event:',
+    '    inner (produce-long-stack-traces.js:20:10)',
+    'From previous event:',
+    '    outer (produce-long-stack-traces.js:19:27)',
+    'From previous event:',
+    '    Object.<anonymous> (produce-long-stack-traces.js:18:43)'
+  ]);
+
+  t.match(cleanedStack, expected);
 });
 
-test.cb('removes empty "Caused by:" sections from the top', t => {
-	nestedErrors.top(stack => {
-		const cleanedStack = stackUtils.clean(stack);
+t.test('removes empty "Caused by:" sections from the top', t => {
+  nestedErrors.top(stack => {
+    const cleanedStack = stackUtils.clean(stack);
 
-		const expected = join([
-			'Caused By: Error: baz',
-			'    Object.module.exports.top (nested-errors.js:36:5)'
-		]);
+    const expected = join([
+      'Caused By: Error: baz',
+      '    Object.module.exports.top (nested-errors.js:36:5)'
+    ]);
 
-		t.is(cleanedStack, expected);
-		t.end();
-	});
+    t.match(cleanedStack, expected);
+    t.end();
+  });
 });
 
-test.cb('removes empty "Caused by:" sections from the bottom', t => {
-	nestedErrors.bottom(stack => {
-		const cleanedStack = stackUtils.clean(stack);
+t.test('removes empty "Caused by:" sections from the bottom', t => {
+  nestedErrors.bottom(stack => {
+    const cleanedStack = stackUtils.clean(stack);
 
-		const expected = join([
-			'nested (nested-errors.js:9:6)',
-			'moreNested (nested-errors.js:15:3)',
-			'Caused By: BarError: bar: internal',
-			'    moreNested (nested-errors.js:15:6)'
-		]);
+    const expected = join([
+      'nested (nested-errors.js:9:6)',
+      'moreNested (nested-errors.js:15:3)',
+      'Caused By: BarError: bar: internal',
+      '    moreNested (nested-errors.js:15:6)'
+    ]);
 
-		t.is(cleanedStack, expected);
-		t.end();
-	});
+    t.is(cleanedStack, expected);
+    t.end();
+  });
 });
 
-test.cb('removes empty "Caused by:" sections from the middle', t => {
-	nestedErrors.middle(stack => {
-		const cleanedStack = stackUtils.clean(stack);
+t.test('removes empty "Caused by:" sections from the middle', t => {
+  nestedErrors.middle(stack => {
+    const cleanedStack = stackUtils.clean(stack);
 
-		const expected = join([
-			'nested-errors.js:41:6',
-			'Caused By: Error: bar',
-			'    Object.module.exports.middle (nested-errors.js:42:5)'
-		]);
+    const expected = join([
+      'nested-errors.js:41:6',
+      'Caused By: Error: bar',
+      '    Object.module.exports.middle (nested-errors.js:42:5)'
+    ]);
 
-		t.is(cleanedStack, expected);
-		t.end();
-	});
+    t.match(cleanedStack, expected);
+    t.end();
+  });
 });
diff --git a/test/test.js b/test/test.js
index 39cc5ef..6bb8634 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,471 +1,493 @@
-import path from 'path';
-import test from 'ava';
-import StackUtils from '../';
-import CaptureFixture from './fixtures/capture-fixture';
-import {join, fixtureDir} from './_utils';
+const path = require('path');
+const t = require('tap');
+const StackUtils = require('../');
+const CaptureFixture = require('./fixtures/capture-fixture');
+const {join, fixtureDir} = require('./_utils');
 
 // Use a fixed known set of native modules, since this changes
 // depending on the version of Node we're testing with.
 StackUtils.natives = [
-	'internal/bootstrap_node',
-	'_debug_agent',
-	'_debugger',
-	'assert',
-	'buffer',
-	'child_process',
-	'console',
-	'constants',
-	'crypto',
-	'cluster',
-	'dgram',
-	'dns',
-	'domain',
-	'events',
-	'fs',
-	'http',
-	'_http_agent',
-	'_http_client',
-	'_http_common',
-	'_http_incoming',
-	'_http_outgoing',
-	'_http_server',
-	'https',
-	'_linklist',
-	'module',
-	'net',
-	'os',
-	'path',
-	'process',
-	'punycode',
-	'querystring',
-	'readline',
-	'repl',
-	'stream',
-	'_stream_readable',
-	'_stream_writable',
-	'_stream_duplex',
-	'_stream_transform',
-	'_stream_passthrough',
-	'_stream_wrap',
-	'string_decoder',
-	'sys',
-	'timers',
-	'tls',
-	'_tls_common',
-	'_tls_legacy',
-	'_tls_wrap',
-	'tty',
-	'url',
-	'util',
-	'v8',
-	'vm',
-	'zlib',
-	'internal/buffer',
-	'internal/child_process',
-	'internal/cluster',
-	'internal/freelist',
-	'internal/fs',
-	'internal/linkedlist',
-	'internal/net',
-	'internal/module',
-	'internal/process/next_tick',
-	'internal/process/promises',
-	'internal/process/stdio',
-	'internal/process/warning',
-	'internal/process',
-	'internal/readline',
-	'internal/repl',
-	'internal/socket_list',
-	'internal/url',
-	'internal/util',
-	'internal/v8_prof_polyfill',
-	'internal/v8_prof_processor',
-	'internal/streams/lazy_transform',
-	'internal/streams/BufferList',
-	'v8/tools/splaytree',
-	'v8/tools/codemap',
-	'v8/tools/consarray',
-	'v8/tools/csvparser',
-	'v8/tools/profile',
-	'v8/tools/profile_view',
-	'v8/tools/logreader',
-	'v8/tools/tickprocessor',
-	'v8/tools/SourceMap',
-	'v8/tools/tickprocessor-driver',
-	'bootstrap_node',
-	'node'
+  'internal/bootstrap_node',
+  '_debug_agent',
+  '_debugger',
+  'assert',
+  'buffer',
+  'child_process',
+  'console',
+  'constants',
+  'crypto',
+  'cluster',
+  'dgram',
+  'dns',
+  'domain',
+  'events',
+  'fs',
+  'http',
+  '_http_agent',
+  '_http_client',
+  '_http_common',
+  '_http_incoming',
+  '_http_outgoing',
+  '_http_server',
+  'https',
+  '_linklist',
+  'module',
+  'net',
+  'os',
+  'path',
+  'process',
+  'punycode',
+  'querystring',
+  'readline',
+  'repl',
+  'stream',
+  '_stream_readable',
+  '_stream_writable',
+  '_stream_duplex',
+  '_stream_transform',
+  '_stream_passthrough',
+  '_stream_wrap',
+  'string_decoder',
+  'sys',
+  'timers',
+  'tls',
+  '_tls_common',
+  '_tls_legacy',
+  '_tls_wrap',
+  'tty',
+  'url',
+  'util',
+  'v8',
+  'vm',
+  'zlib',
+  'internal/buffer',
+  'internal/child_process',
+  'internal/cluster',
+  'internal/freelist',
+  'internal/fs',
+  'internal/linkedlist',
+  'internal/net',
+  'internal/module',
+  'internal/process/next_tick',
+  'internal/process/promises',
+  'internal/process/stdio',
+  'internal/process/warning',
+  'internal/process',
+  'internal/readline',
+  'internal/repl',
+  'internal/socket_list',
+  'internal/url',
+  'internal/util',
+  'internal/v8_prof_polyfill',
+  'internal/v8_prof_processor',
+  'internal/streams/lazy_transform',
+  'internal/streams/BufferList',
+  'v8/tools/splaytree',
+  'v8/tools/codemap',
+  'v8/tools/consarray',
+  'v8/tools/csvparser',
+  'v8/tools/profile',
+  'v8/tools/profile_view',
+  'v8/tools/logreader',
+  'v8/tools/tickprocessor',
+  'v8/tools/SourceMap',
+  'v8/tools/tickprocessor-driver',
+  'bootstrap_node',
+  'node'
 ];
 
 const LinuxStack1 = join(linuxStack1(), internalStack());
 const WindowsStack1 = join(windowsStack1(), internalStack());
 
 const version = process.version.slice(1).split('.').map(function (val) {
-	return parseInt(val, 10);
+  return parseInt(val, 10);
 });
 
-test('must be called with new', t => {
-	t.is(typeof StackUtils, 'function');
-	const stackUtils = StackUtils;
-	t.throws(() => stackUtils());
+t.test('must be called with new', t => {
+  t.is(typeof StackUtils, 'function');
+  const stackUtils = StackUtils;
+  t.throws(() => stackUtils());
+  t.end()
 });
 
-test('clean: truncates cwd', t => {
-	const expected = join([
-		'foo (foo.js:3:8)',
-		'bar (foo.js:7:2)',
-		'bar (bar.js:4:2)',
-		'Object.<anonymous> (bar.js:7:1)',
-		'ontimeout (timers.js:365:14)',
-		'tryOnTimeout (timers.js:237:5)',
-		'Timer.listOnTimeout (timers.js:207:5)',
-		'_combinedTickCallback (internal/process/next_tick.js:67:7)',
-		'process._tickCallback (internal/process/next_tick.js:98:9)',
-		'Module.runMain (module.js:645:11)',
-		'Module._compile (module.js:398:26)',
-		'Object.Module._extensions..js (module.js:405:10)',
-		'Module.load (module.js:344:32)',
-		'Function.Module._load (module.js:301:12)',
-		'Function.Module.runMain (module.js:430:10)',
-		'run (bootstrap_node.js:420:7)',
-		'startup (bootstrap_node.js:139:9)',
-		'bootstrap_node.js:535:3',
-		'startup (node.js:141:18)'
-	]);
-
-	let stack = new StackUtils({cwd: '/user/dev/project'});
-	t.is(stack.clean(LinuxStack1), expected, 'accepts a linux string');
-	t.is(stack.clean(LinuxStack1.split('\n')), expected, 'accepts an array');
-	t.is(stack.clean(LinuxStack1.split('\n').slice(1)), expected, 'slices off the message line');
-
-	stack = new StackUtils({cwd: 'Z:\\user\\dev\\project'});
-	t.is(stack.clean(WindowsStack1), expected, 'accepts a windows string');
+t.test('clean: truncates cwd', t => {
+  const expected = join([
+    'foo (foo.js:3:8)',
+    'bar (foo.js:7:2)',
+    'bar (bar.js:4:2)',
+    'Object.<anonymous> (bar.js:7:1)',
+    'ontimeout (timers.js:365:14)',
+    'tryOnTimeout (timers.js:237:5)',
+    'Timer.listOnTimeout (timers.js:207:5)',
+    '_combinedTickCallback (internal/process/next_tick.js:67:7)',
+    'process._tickCallback (internal/process/next_tick.js:98:9)',
+    'Module.runMain (module.js:645:11)',
+    'Module._compile (module.js:398:26)',
+    'Object.Module._extensions..js (module.js:405:10)',
+    'Module.load (module.js:344:32)',
+    'Function.Module._load (module.js:301:12)',
+    'Function.Module.runMain (module.js:430:10)',
+    'run (bootstrap_node.js:420:7)',
+    'startup (bootstrap_node.js:139:9)',
+    'bootstrap_node.js:535:3',
+    'startup (node.js:141:18)'
+  ]);
+
+  let stack = new StackUtils({cwd: '/user/dev/project'});
+  t.is(stack.clean(LinuxStack1), expected, 'accepts a linux string');
+  t.is(stack.clean(LinuxStack1.split('\n')), expected, 'accepts an array');
+  t.is(stack.clean(LinuxStack1.split('\n').slice(1)), expected, 'slices off the message line');
+
+  stack = new StackUtils({cwd: 'Z:\\user\\dev\\project'});
+  t.is(stack.clean(WindowsStack1), expected, 'accepts a windows string');
+  t.end()
 });
 
-test('clean: eliminates internals', t => {
-	let stack = new StackUtils({cwd: '/user/dev', internals: StackUtils.nodeInternals()});
-	var expected = join([
-		'foo (project/foo.js:3:8)',
-		'bar (project/foo.js:7:2)',
-		'bar (project/bar.js:4:2)',
-		'Object.<anonymous> (project/bar.js:7:1)'
-	]);
-	t.is(stack.clean(LinuxStack1), expected);
-
-	stack = new StackUtils({cwd: 'Z:\\user\\dev', internals: StackUtils.nodeInternals()});
-	t.is(stack.clean(WindowsStack1), expected);
+t.test('clean: eliminates internals', t => {
+  let stack = new StackUtils({cwd: '/user/dev', internals: StackUtils.nodeInternals()});
+  var expected = join([
+    'foo (project/foo.js:3:8)',
+    'bar (project/foo.js:7:2)',
+    'bar (project/bar.js:4:2)',
+    'Object.<anonymous> (project/bar.js:7:1)'
+  ]);
+  t.is(stack.clean(LinuxStack1), expected);
+
+  stack = new StackUtils({cwd: 'Z:\\user\\dev', internals: StackUtils.nodeInternals()});
+  t.is(stack.clean(WindowsStack1), expected);
+  t.end()
 });
 
-test('clean: returns null if it is all internals', t => {
-	const stack = new StackUtils({internals: StackUtils.nodeInternals()});
-	t.is(stack.clean(join(internalStack())), '');
+t.test('clean: returns null if it is all internals', t => {
+  const stack = new StackUtils({internals: StackUtils.nodeInternals()});
+  t.is(stack.clean(join(internalStack())), '');
+  t.end()
 });
 
-test('captureString: two redirects', t => {
-	const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stack);
-
-	const capturedString = capture.redirect1('redirect2', 'call', 'captureString');
-	t.is(capturedString, join([
-		'CaptureFixture.call (capture-fixture.js:23:28)',
-		'CaptureFixture.redirect2 (capture-fixture.js:17:22)',
-		'CaptureFixture.redirect1 (capture-fixture.js:11:22)'
-	]));
+t.test('captureString: two redirects', t => {
+  const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stack);
+
+  const capturedString = capture.redirect1('redirect2', 'call', 'captureString');
+  t.is(capturedString, join([
+    'CaptureFixture.call (capture-fixture.js:23:28)',
+    'CaptureFixture.redirect2 (capture-fixture.js:17:22)',
+    'CaptureFixture.redirect1 (capture-fixture.js:11:22)'
+  ]));
+  t.end()
 });
 
-test('captureString: with startStack function', t => {
-	const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stack);
+t.test('captureString: with startStack function', t => {
+  const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stack);
 
-	const capturedString = capture.redirect1('redirect2', 'call', 'captureString', capture.call);
-	t.is(capturedString, join([
-		'CaptureFixture.redirect2 (capture-fixture.js:17:22)',
-		'CaptureFixture.redirect1 (capture-fixture.js:11:22)'
-	]));
+  const capturedString = capture.redirect1('redirect2', 'call', 'captureString', capture.call);
+  t.is(capturedString, join([
+    'CaptureFixture.redirect2 (capture-fixture.js:17:22)',
+    'CaptureFixture.redirect1 (capture-fixture.js:11:22)'
+  ]));
+  t.end()
 });
 
-test('captureString: with limit', t => {
-	const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stack);
+t.test('captureString: with limit', t => {
+  const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stack);
 
-	const capturedString = capture.redirect1('redirect2', 'call', 'captureString', 1);
-	t.is(capturedString, join([
-		'CaptureFixture.call (capture-fixture.js:23:28)'
-	]));
+  const capturedString = capture.redirect1('redirect2', 'call', 'captureString', 1);
+  t.is(capturedString, join([
+    'CaptureFixture.call (capture-fixture.js:23:28)'
+  ]));
+  t.end()
 });
 
-test('captureString: with limit and startStack', t => {
-	const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stack);
+t.test('captureString: with limit and startStack', t => {
+  const stack = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stack);
 
-	const capturedString = capture.redirect1('redirect2', 'call', 'captureString', 1, capture.call);
-	t.is(capturedString, join([
-		'CaptureFixture.redirect2 (capture-fixture.js:17:22)'
-	]));
+  const capturedString = capture.redirect1('redirect2', 'call', 'captureString', 1, capture.call);
+  t.is(capturedString, join([
+    'CaptureFixture.redirect2 (capture-fixture.js:17:22)'
+  ]));
+  t.end()
 });
 
-test('capture returns an array of call sites', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stackUtil);
-	const stack = capture.redirect1('call', 'capture').slice(0, 2);
-	t.is(stack[0].getFileName(), path.join(fixtureDir, 'capture-fixture.js'));
-	t.is(stack[0].getFunctionName(), 'CaptureFixture.call');
-	t.is(stack[1].getFunctionName(), 'CaptureFixture.redirect1');
+t.test('capture returns an array of call sites', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stackUtil);
+  const stack = capture.redirect1('call', 'capture').slice(0, 2);
+  t.is(stack[0].getFileName(), path.join(fixtureDir, 'capture-fixture.js'));
+  t.is(stack[0].getFunctionName(), 'CaptureFixture.call');
+  t.is(stack[1].getFunctionName(), 'CaptureFixture.redirect1');
+  t.end()
 });
 
-test('capture: with limit', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stackUtil);
-	const stack = capture.redirect1('redirect2', 'call', 'capture', 1);
-	t.is(stack.length, 1);
-	t.is(stack[0].getFunctionName(), 'CaptureFixture.call');
+t.test('capture: with limit', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stackUtil);
+  const stack = capture.redirect1('redirect2', 'call', 'capture', 1);
+  t.is(stack.length, 1);
+  t.is(stack[0].getFunctionName(), 'CaptureFixture.call');
+  t.end()
 });
 
-test('capture: with stackStart function', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stackUtil);
-	const stack = capture.redirect1('redirect2', 'call', 'capture', capture.call);
-	t.true(stack.length > 1);
-	t.is(stack[0].getFunctionName(), 'CaptureFixture.redirect2');
+t.test('capture: with stackStart function', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stackUtil);
+  const stack = capture.redirect1('redirect2', 'call', 'capture', capture.call);
+  t.true(stack.length > 1);
+  t.is(stack[0].getFunctionName(), 'CaptureFixture.redirect2');
+  t.end()
 });
 
-test('capture: with limit and stackStart function', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stackUtil);
-	const stack = capture.redirect1('redirect2', 'call', 'capture', 1, capture.call);
-	t.is(stack.length, 1);
-	t.is(stack[0].getFunctionName(), 'CaptureFixture.redirect2');
+t.test('capture: with limit and stackStart function', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stackUtil);
+  const stack = capture.redirect1('redirect2', 'call', 'capture', 1, capture.call);
+  t.is(stack.length, 1);
+  t.is(stack[0].getFunctionName(), 'CaptureFixture.redirect2');
+  t.end()
 });
 
-test('capture: with wrapCallSite function', t => {
-	const wrapper = function (callsite) {
-		return {
-			getMethodName: function () {
-				return callsite.getMethodName();
-			},
-			getFunctionName: function () {
-				return 'testOverrideFunctionName';
-			}
-		};
-	};
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir, wrapCallSite: wrapper});
-	const capture = new CaptureFixture(stackUtil);
-	const stack = capture.redirect1('redirect2', 'call', 'capture', 1, capture.call);
-	t.is(stack.length, 1);
-	t.is(stack[0].getFunctionName(), 'testOverrideFunctionName');
-	t.is(stack[0].getMethodName(), 'redirect2');
+t.test('capture: with wrapCallSite function', t => {
+  const wrapper = function (callsite) {
+    return {
+      getMethodName: function () {
+        return callsite.getMethodName();
+      },
+      getFunctionName: function () {
+        return 'testOverrideFunctionName';
+      }
+    };
+  };
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir, wrapCallSite: wrapper});
+  const capture = new CaptureFixture(stackUtil);
+  const stack = capture.redirect1('redirect2', 'call', 'capture', 1, capture.call);
+  t.is(stack.length, 1);
+  t.is(stack[0].getFunctionName(), 'testOverrideFunctionName');
+  t.is(stack[0].getMethodName(), 'redirect2');
+  t.end()
 });
 
-test('at', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stackUtil);
-	const at = capture.redirect1('call', 'at');
-
-	t.same(at, {
-		file: 'capture-fixture.js',
-		line: 23,
-		column: 28,
-		type: 'CaptureFixture',
-		function: 'CaptureFixture.call',
-		method: 'call'
-	});
+t.test('at', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stackUtil);
+  const at = capture.redirect1('call', 'at');
+
+  t.same(at, {
+    file: 'capture-fixture.js',
+    line: 23,
+    column: 28,
+    type: 'CaptureFixture',
+    function: 'CaptureFixture.call',
+    method: 'call'
+  });
+  t.end()
 });
 
-test('at: with stackStart', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: __dirname});
-	const capture = new CaptureFixture(stackUtil);
-
-	const at = capture.redirect1('call', 'at', capture.call);
-
-	t.same(at, {
-		file: `fixtures/capture-fixture.js`,
-		line: 11,
-		column: 22,
-		type: 'CaptureFixture',
-		function: 'CaptureFixture.redirect1',
-		method: 'redirect1'
-	});
+t.test('at: with stackStart', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: __dirname});
+  const capture = new CaptureFixture(stackUtil);
+
+  const at = capture.redirect1('call', 'at', capture.call);
+
+  t.same(at, {
+    file: `fixtures/capture-fixture.js`,
+    line: 11,
+    column: 22,
+    type: 'CaptureFixture',
+    function: 'CaptureFixture.redirect1',
+    method: 'redirect1'
+  });
+  t.end()
 });
 
-test('at: inside a constructor call', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stackUtil);
-
-	const at = capture.const('call', 'at', capture.call);
-
-	// TODO: File an issue - if this assert fails, the power assert diagram renderer blows up.
-	t.same(at, {
-		file: 'capture-fixture.js',
-		line: 32,
-		column: 27,
-		constructor: true,
-		type: 'Constructor',
-		function: 'Constructor'
-	});
+t.test('at: inside a constructor call', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stackUtil);
+
+  const at = capture.const('call', 'at', capture.call);
+
+  // TODO: File an issue - if this assert fails, the power assert diagram renderer blows up.
+  t.same(at, {
+    file: 'capture-fixture.js',
+    line: 32,
+    column: 27,
+    constructor: true,
+    type: 'Constructor',
+    function: 'Constructor'
+  });
+  t.end()
 });
 
-test('at: method on an [Object] instance', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stackUtil);
+t.test('at: method on an [Object] instance', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stackUtil);
 
-	const at = capture.const('obj', 'foo', 'call', 'at', capture.call);
+  const at = capture.const('obj', 'foo', 'call', 'at', capture.call);
 
-	t.same(at, {
-		file: 'capture-fixture.js',
-		line: 46,
-		column: 23,
-		function: 'obj.(anonymous function)',
-		method: 'foo'
-	});
+  t.same(at, {
+    file: 'capture-fixture.js',
+    line: 46,
+    column: 23,
+    function: 'obj.(anonymous function)',
+    method: 'foo'
+  });
+  t.end()
 });
 
-test('at: returns empty object if #capture() returns an empty stack', t => {
-	const stackUtil = new StackUtils();
-	stackUtil.capture = function () {
-		return [];
-	};
-	t.same(stackUtil.at(), {});
+t.test('at: returns empty object if #capture() returns an empty stack', t => {
+  const stackUtil = new StackUtils();
+  stackUtil.capture = function () {
+    return [];
+  };
+  t.same(stackUtil.at(), {});
+  t.end()
 });
 
-test('at: eval', t => {
-	const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
-	const capture = new CaptureFixture(stackUtil);
-
-	const at = capture.eval('call', 'at', capture.call);
-	const expected = {
-		line: 1,
-		column: 14,
-		evalOrigin: 'eval at <anonymous> (' + path.join(fixtureDir, 'capture-fixture.js') + ':57:9)',
-		function: 'eval'
-	};
-
-	// TODO: There are some inconsistencies between this and how `parseLine` works.
-	if (version[0] < 4) {
-		expected.type = 'CaptureFixture';
-		expected.function = 'eval';
-	}
-
-	t.same(at, expected);
+t.test('at: eval', t => {
+  const stackUtil = new StackUtils({internals: internals(), cwd: fixtureDir});
+  const capture = new CaptureFixture(stackUtil);
+
+  const at = capture.eval('call', 'at', capture.call);
+  const expected = {
+    line: 1,
+    column: 14,
+    evalOrigin: /eval at (<anonymous>|CaptureFixture.eval) \(.*capture-fixture.js:57:9\)/,
+    function: 'eval'
+  };
+
+  // TODO: There are some inconsistencies between this and how `parseLine` works.
+  if (version[0] < 4) {
+    expected.type = 'CaptureFixture';
+    expected.function = 'eval';
+  }
+
+  t.match(at, expected);
+  t.end()
 });
 
-test('parseLine', t => {
-	const stack = new StackUtils({internals: internals(), cwd: '/user/dev/project'});
-	const capture = new CaptureFixture(stack);
-
-	t.same(stack.parseLine('foo'), null, 'should not match');
-
-	t.same(stack.parseLine('    at bar (/user/dev/project/foo.js:3:8)'), {
-		file: 'foo.js',
-		line: 3,
-		column: 8,
-		function: 'bar'
-	});
-
-	t.same(stack.parseLine('    at SomeClass.someFunc (/user/dev/project/foo.js:3:8)'), {
-		file: 'foo.js',
-		line: 3,
-		column: 8,
-		function: 'SomeClass.someFunc'
-	});
-
-	t.same(stack.parseLine('    at foo (/some/other/dir/file.js:3:8)'), {
-		file: '/some/other/dir/file.js',
-		line: 3,
-		column: 8,
-		function: 'foo'
-	});
-
-	// TODO: report issue - this also causes power-assert diagram renderer to fail
-	t.same(stack.parseLine('    at new Foo (/user/dev/project/foo.js:3:8)'), {
-		file: 'foo.js',
-		line: 3,
-		column: 8,
-		constructor: true,
-		function: 'Foo'
-	});
-
-	// EVAL
-	const evalStack = capture.eval('error', 'foo').stack.split('\n');
-
-	const expected = {
-		file: '<anonymous>',
-		line: 1,
-		column: 14,
-		evalOrigin: '<anonymous>',
-		evalLine: 57,
-		evalColumn: 9,
-		evalFile: path.join(fixtureDir, 'capture-fixture.js').replace(/\\/g, '/'),
-		function: 'eval'
-	};
-
-	if (version[0] < 4) {
-		expected.function = 'CaptureFixture.eval';
-	}
-
-	const actual = stack.parseLine(evalStack[2]);
-
-	t.same(actual, expected);
+t.test('parseLine', t => {
+  const stack = new StackUtils({internals: internals(), cwd: '/user/dev/project'});
+  const capture = new CaptureFixture(stack);
+
+  t.same(stack.parseLine('foo'), null, 'should not match');
+
+  t.same(stack.parseLine('    at bar (/user/dev/project/foo.js:3:8)'), {
+    file: 'foo.js',
+    line: 3,
+    column: 8,
+    function: 'bar'
+  });
+
+  t.same(stack.parseLine('    at SomeClass.someFunc (/user/dev/project/foo.js:3:8)'), {
+    file: 'foo.js',
+    line: 3,
+    column: 8,
+    function: 'SomeClass.someFunc'
+  });
+
+  t.same(stack.parseLine('    at foo (/some/other/dir/file.js:3:8)'), {
+    file: '/some/other/dir/file.js',
+    line: 3,
+    column: 8,
+    function: 'foo'
+  });
+
+  // TODO: report issue - this also causes power-assert diagram renderer to fail
+  t.same(stack.parseLine('    at new Foo (/user/dev/project/foo.js:3:8)'), {
+    file: 'foo.js',
+    line: 3,
+    column: 8,
+    constructor: true,
+    function: 'Foo'
+  });
+
+  // EVAL
+  const evalStack = capture.eval('error', 'foo').stack.split('\n');
+
+  const expected = {
+    file: '<anonymous>',
+    line: 1,
+    column: 14,
+    evalOrigin: /CaptureFixture.eval|<anonymous>/,
+    evalLine: 57,
+    evalColumn: 9,
+    evalFile: path.join(fixtureDir, 'capture-fixture.js').replace(/\\/g, '/'),
+    function: 'eval'
+  };
+
+  if (version[0] < 4) {
+    expected.function = 'CaptureFixture.eval';
+  }
+
+  const actual = stack.parseLine(evalStack[2]);
+
+  t.match(actual, expected);
+  t.end()
 });
 
-test('parseLine: handles native errors', t => {
-	t.same(StackUtils.parseLine('    at Error (native)'), {
-		native: true,
-		function: 'Error'
-	});
+t.test('parseLine: handles native errors', t => {
+  t.same(StackUtils.parseLine('    at Error (native)'), {
+    native: true,
+    function: 'Error'
+  });
+  t.end()
 });
 
-test('parseLine: handles parens', t => {
-	var line = '    at X.<anonymous> (/USER/Db (Person)/x/y.js:14:11)';
-	t.same(StackUtils.parseLine(line), {
-		line: 14,
-		column: 11,
-		file: '/USER/Db (Person)/x/y.js',
-		function: 'X.<anonymous>'
-	});
+t.test('parseLine: handles parens', t => {
+  var line = '    at X.<anonymous> (/USER/Db (Person)/x/y.js:14:11)';
+  t.same(StackUtils.parseLine(line), {
+    line: 14,
+    column: 11,
+    file: '/USER/Db (Person)/x/y.js',
+    function: 'X.<anonymous>'
+  });
+  t.end()
 });
 
 function linuxStack1() {
-	return [
-		'Error: foo',
-		'    at foo (/user/dev/project/foo.js:3:8)',
-		'    at bar (/user/dev/project/foo.js:7:2)',
-		'    at bar (/user/dev/project/bar.js:4:2)',
-		'    at Object.<anonymous> (/user/dev/project/bar.js:7:1)'
-	];
+  return [
+    'Error: foo',
+    '    at foo (/user/dev/project/foo.js:3:8)',
+    '    at bar (/user/dev/project/foo.js:7:2)',
+    '    at bar (/user/dev/project/bar.js:4:2)',
+    '    at Object.<anonymous> (/user/dev/project/bar.js:7:1)'
+  ];
 }
 
 function windowsStack1() {
-	return [
-		'Error: foo',
-		'    at foo (Z:\\user\\dev\\project\\foo.js:3:8)',
-		'    at bar (Z:\\user\\dev\\project\\foo.js:7:2)',
-		'    at bar (Z:\\user\\dev\\project\\bar.js:4:2)',
-		'    at Object.<anonymous> (Z:\\user\\dev\\project\\bar.js:7:1)'
-	];
+  return [
+    'Error: foo',
+    '    at foo (Z:\\user\\dev\\project\\foo.js:3:8)',
+    '    at bar (Z:\\user\\dev\\project\\foo.js:7:2)',
+    '    at bar (Z:\\user\\dev\\project\\bar.js:4:2)',
+    '    at Object.<anonymous> (Z:\\user\\dev\\project\\bar.js:7:1)'
+  ];
 }
 
 function internalStack() {
-	return [
-		'    at ontimeout (timers.js:365:14)',
-		'    at tryOnTimeout (timers.js:237:5)',
-		'    at Timer.listOnTimeout (timers.js:207:5)',
-		'    at _combinedTickCallback (internal/process/next_tick.js:67:7)',
-		'    at process._tickCallback (internal/process/next_tick.js:98:9)',
-		'    at Module.runMain (module.js:645:11)',
-		'    at Module._compile (module.js:398:26)',
-		'    at Object.Module._extensions..js (module.js:405:10)',
-		'    at Module.load (module.js:344:32)',
-		'    at Function.Module._load (module.js:301:12)',
-		'    at Function.Module.runMain (module.js:430:10)',
-		'    at run (bootstrap_node.js:420:7)',
-		'    at startup (bootstrap_node.js:139:9)',
-		'    at bootstrap_node.js:535:3',
-		'    at startup (node.js:141:18)'
-	];
+  return [
+    '    at ontimeout (timers.js:365:14)',
+    '    at tryOnTimeout (timers.js:237:5)',
+    '    at Timer.listOnTimeout (timers.js:207:5)',
+    '    at _combinedTickCallback (internal/process/next_tick.js:67:7)',
+    '    at process._tickCallback (internal/process/next_tick.js:98:9)',
+    '    at Module.runMain (module.js:645:11)',
+    '    at Module._compile (module.js:398:26)',
+    '    at Object.Module._extensions..js (module.js:405:10)',
+    '    at Module.load (module.js:344:32)',
+    '    at Function.Module._load (module.js:301:12)',
+    '    at Function.Module.runMain (module.js:430:10)',
+    '    at run (bootstrap_node.js:420:7)',
+    '    at startup (bootstrap_node.js:139:9)',
+    '    at bootstrap_node.js:535:3',
+    '    at startup (node.js:141:18)'
+  ];
 }
 
 function internals() {
-	return StackUtils.nodeInternals().concat([
-		/test\.js:\d+:\d+\)?$/,
-		/\/node_modules\//
-	]);
+  return StackUtils.nodeInternals().concat([
+    /test\.js:\d+:\d+\)?$/,
+    /\/node_modules\//
+  ]);
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stack-utils.git



More information about the Pkg-javascript-commits mailing list