refactor(Cypress): add nodemodules
This commit is contained in:
5
node_modules/stack-chain/.npmignore
generated
vendored
Normal file
5
node_modules/stack-chain/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
/node_modules/
|
||||
/test/temp/
|
||||
npm-debug.log
|
||||
|
7
node_modules/stack-chain/.travis.yml
generated
vendored
Normal file
7
node_modules/stack-chain/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "stable"
|
||||
- "4"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
sudo: false
|
19
node_modules/stack-chain/LICENSE.md
generated
vendored
Normal file
19
node_modules/stack-chain/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2012 Andreas Madsen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
159
node_modules/stack-chain/README.md
generated
vendored
Normal file
159
node_modules/stack-chain/README.md
generated
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
# stack-chain [](http://travis-ci.org/AndreasMadsen/stack-chain)
|
||||
|
||||
> API for combining call site modifyers
|
||||
|
||||
## Installation
|
||||
|
||||
```sheel
|
||||
npm install stack-chain
|
||||
```
|
||||
## API documentation
|
||||
|
||||
```JavaScript
|
||||
var chain = require('stack-chain');
|
||||
```
|
||||
|
||||
When the `Error.stack` getter is executed, the `stack-chain` will perform the
|
||||
following:
|
||||
|
||||
1. execute the `modifiers` attached by `chain.extend`.
|
||||
2. execute the `modifiers` attached by `chain.filter`.
|
||||
3. execute the `formater` set by `chain.format.replace`.
|
||||
|
||||
### chain.extend.attach(modifier)
|
||||
### chain.filter.attach(modifier)
|
||||
|
||||
Will modify the callSite array. Note you shouldn't format the stack trace.
|
||||
|
||||
The `modifier` is a function there takes two arguments `error` and `frames`.
|
||||
|
||||
* `error` is the `Error` object.
|
||||
* `frames` is an array of `callSite` objects, see
|
||||
[v8 documentation](https://github.com/v8/v8/wiki/Stack-Trace-API)
|
||||
for details.
|
||||
|
||||
When the `modifier` is done, it should `return` a modified `frames` array.
|
||||
|
||||
```JavaScript
|
||||
chain.filter.attach(function (error, frames) {
|
||||
|
||||
// Filter out traces related to this file
|
||||
var rewrite = frames.filter(function (callSite) {
|
||||
return callSite.getFileName() !== module.filename;
|
||||
});
|
||||
|
||||
return rewrite;
|
||||
});
|
||||
```
|
||||
|
||||
### chain.extend.deattach(modifier)
|
||||
### chain.filter.deattach(modifier)
|
||||
|
||||
Removes a `modifier` function from the list of `modifiers`.
|
||||
|
||||
```JavaScript
|
||||
var modifier = function () {};
|
||||
|
||||
// Attach modifier function
|
||||
chain.extend.attach(modifier);
|
||||
|
||||
// Deattach modifier function
|
||||
chain.extend.deattach(modifier);
|
||||
```
|
||||
|
||||
### chain.format.replace(formater)
|
||||
|
||||
Replaces the default v8 `formater`. The new `formater` takes a two arguments
|
||||
`error` and `frames`.
|
||||
|
||||
* `error` is the `Error` object.
|
||||
* `callSites` is an array of `callSite` objects, see
|
||||
[v8 documentation](https://github.com/v8/v8/wiki/Stack-Trace-API)
|
||||
for details.
|
||||
|
||||
When the `formater` is done, it should `return` a `string`. The `string` will
|
||||
what `Error.stack` returns.
|
||||
|
||||
```JavaScript
|
||||
chain.format.replace(function (error, frames) {
|
||||
var lines = [];
|
||||
|
||||
lines.push(error.toString());
|
||||
|
||||
for (var i = 0; i < frames.length; i++) {
|
||||
lines.push(" at " + frames[i].toString());
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
});
|
||||
```
|
||||
|
||||
### chain.format.restore()
|
||||
|
||||
Will restore the default v8 `formater`. Note that dude to the nature of v8
|
||||
`Error` objects, if one of the getters `Error.stack` or `Error.callSite` has
|
||||
already executed, the value of `Error.stack` won't change.
|
||||
|
||||
### chain.callSite([options])
|
||||
|
||||
This will return the unmodified `callSite` array from the current tick. This
|
||||
is a performance shortcut, as it does not require generating the `.stack`
|
||||
string. This behaviour is different from the `Error().callSite` properties.
|
||||
|
||||
While this is mostly generating `callSite` in hot code, it can be useful to
|
||||
do some modification on the array. The `options` object, supports the following:
|
||||
|
||||
```javascript
|
||||
options = {
|
||||
// (default false) run the extenders on the callSite array.
|
||||
extend: true,
|
||||
|
||||
// (default false) run the filters on the callSite array.
|
||||
filter: true,
|
||||
|
||||
// (default 0) before running extend or filter methods, slice of some of the
|
||||
// end. This can be useful for hiding the place from where you called this
|
||||
// function.
|
||||
slice: 2
|
||||
}
|
||||
```
|
||||
|
||||
### chain.originalCallSite(error)
|
||||
|
||||
Returns the original `callSite` array.
|
||||
|
||||
### chain.mutatedCallSite(error)
|
||||
|
||||
Returns the mutated `callSite` array, that is after `extend` and `filter`
|
||||
is applied. The array will not exceed the `Error.stackTraceLimit`.
|
||||
|
||||
### Error.stackTraceLimit
|
||||
|
||||
This limites the size of the `callSites` array. The default value is 10, and
|
||||
can be set to any positive number including `Infinity`. See
|
||||
[v8 documentation](https://github.com/v8/v8/wiki/Stack-Trace-API)
|
||||
for details.
|
||||
|
||||
## License
|
||||
|
||||
**The software is license under "MIT"**
|
||||
|
||||
> Copyright (c) 2012 Andreas Madsen
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
55
node_modules/stack-chain/benchmark.js
generated
vendored
Normal file
55
node_modules/stack-chain/benchmark.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
var chain = require('./stack-chain.js');
|
||||
var summary = require('summary');
|
||||
var assert = require('assert');
|
||||
|
||||
function timeit(top, doit) {
|
||||
var times = new Float64Array(top);
|
||||
var total = 0;
|
||||
|
||||
for (var i = 0; i < top; i++) {
|
||||
var tick = process.hrtime();
|
||||
total += doit().length;
|
||||
var tock = process.hrtime(tick);
|
||||
times[i] = tock[0] * 1e9 + tock[1];
|
||||
}
|
||||
|
||||
assert(total, top * doit().length);
|
||||
return summary(times);
|
||||
}
|
||||
|
||||
({
|
||||
'master': function () {
|
||||
var fork = require('child_process').fork;
|
||||
|
||||
function bench(name, callback) {
|
||||
var cp = fork(__filename, [name]);
|
||||
cp.once('message', function (stat) {
|
||||
console.log(name + ': ' + stat.mean.toFixed(4) + ' ± ' + (1.96 * stat.sd).toFixed(4) + ' ns/tick');
|
||||
});
|
||||
cp.once('close', callback);
|
||||
}
|
||||
|
||||
bench('propery', function () {
|
||||
bench('method', function () {
|
||||
console.log('done');
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'propery': function () {
|
||||
var top = 10000;
|
||||
var stat = timeit(top, function () {
|
||||
return (new Error()).callSite.original;
|
||||
});
|
||||
process.send({ "mean": stat.mean(), "sd": stat.sd() });
|
||||
},
|
||||
|
||||
'method': function () {
|
||||
var top = 100000;
|
||||
var stat = timeit(top, function () {
|
||||
return chain.callSite();
|
||||
});
|
||||
process.send({ "mean": stat.mean(), "sd": stat.sd() });
|
||||
}
|
||||
})[process.argv[2] || 'master']();
|
59
node_modules/stack-chain/format.js
generated
vendored
Normal file
59
node_modules/stack-chain/format.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Copyright 2012 the V8 project authors. All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following
|
||||
// disclaimer in the documentation and/or other materials provided
|
||||
// with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
function FormatErrorString(error) {
|
||||
try {
|
||||
return Error.prototype.toString.call(error);
|
||||
} catch (e) {
|
||||
try {
|
||||
return "<error: " + e + ">";
|
||||
} catch (ee) {
|
||||
return "<error>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function FormatStackTrace(error, frames) {
|
||||
var lines = [];
|
||||
lines.push(FormatErrorString(error));
|
||||
for (var i = 0; i < frames.length; i++) {
|
||||
var frame = frames[i];
|
||||
var line;
|
||||
try {
|
||||
line = frame.toString();
|
||||
} catch (e) {
|
||||
try {
|
||||
line = "<error: " + e + ">";
|
||||
} catch (ee) {
|
||||
// Any code that reaches this point is seriously nasty!
|
||||
line = "<error>";
|
||||
}
|
||||
}
|
||||
lines.push(" at " + line);
|
||||
}
|
||||
return lines.join("\n");
|
||||
};
|
16
node_modules/stack-chain/index.js
generated
vendored
Normal file
16
node_modules/stack-chain/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// If a another copy (same version or not) of stack-chain exists it will result
|
||||
// in wrong stack traces (most likely dublicate callSites).
|
||||
if (global._stackChain) {
|
||||
// In case the version match, we can simply return the first initialized copy
|
||||
if (global._stackChain.version === require('./package.json').version) {
|
||||
module.exports = global._stackChain;
|
||||
}
|
||||
// The version don't match, this is really bad. Lets just throw
|
||||
else {
|
||||
throw new Error('Conflicting version of stack-chain found');
|
||||
}
|
||||
}
|
||||
// Yay, no other stack-chain copy exists, yet :/
|
||||
else {
|
||||
module.exports = global._stackChain = require('./stack-chain');
|
||||
}
|
58
node_modules/stack-chain/package.json
generated
vendored
Normal file
58
node_modules/stack-chain/package.json
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"_from": "stack-chain@^2.0.0",
|
||||
"_id": "stack-chain@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-GGrHXePi305aW7XQweYZZwiRwR7Js3MWoK/EHzzB9ROdc75nCnjSJVi21rdAGxFl+yCx2L2qdfl5y7NO4lTyqg==",
|
||||
"_location": "/stack-chain",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "stack-chain@^2.0.0",
|
||||
"name": "stack-chain",
|
||||
"escapedName": "stack-chain",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/cucumber"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-2.0.0.tgz",
|
||||
"_shasum": "d73d1172af89565f07438b5bcc086831b6689b2d",
|
||||
"_spec": "stack-chain@^2.0.0",
|
||||
"_where": "/home/simon/Documents/lifen-autotest/node_modules/cucumber",
|
||||
"author": {
|
||||
"name": "Andreas Madsen",
|
||||
"email": "amwebdk@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/AndreasMadsen/stack-chain/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "API for combining call site modifiers",
|
||||
"devDependencies": {
|
||||
"tap": "2.x.x",
|
||||
"uglify-js": "2.5.x"
|
||||
},
|
||||
"homepage": "https://github.com/AndreasMadsen/stack-chain#readme",
|
||||
"keywords": [
|
||||
"stack",
|
||||
"chain",
|
||||
"trace",
|
||||
"call site",
|
||||
"concat",
|
||||
"format"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "stack-chain",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/AndreasMadsen/stack-chain.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap ./test/simple/*"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
180
node_modules/stack-chain/stack-chain.js
generated
vendored
Normal file
180
node_modules/stack-chain/stack-chain.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
|
||||
// use a already existing formater or fallback to the default v8 formater
|
||||
var defaultFormater = require('./format.js');
|
||||
var originalCallSiteSymbol = Symbol('originalCallSite');
|
||||
var mutatedCallSiteSymbol = Symbol('mutatedCallSite');
|
||||
|
||||
// public define API
|
||||
function stackChain() {
|
||||
this.extend = new TraceModifier();
|
||||
this.filter = new TraceModifier();
|
||||
this.format = new StackFormater();
|
||||
this.version = require('./package.json').version;
|
||||
}
|
||||
|
||||
|
||||
var SHORTCIRCUIT_CALLSITE = false;
|
||||
stackChain.prototype.callSite = function collectCallSites(options) {
|
||||
if (!options) options = {};
|
||||
|
||||
// Get CallSites
|
||||
SHORTCIRCUIT_CALLSITE = true;
|
||||
var obj = {};
|
||||
Error.captureStackTrace(obj, collectCallSites);
|
||||
var callSites = obj.stack;
|
||||
SHORTCIRCUIT_CALLSITE = false;
|
||||
|
||||
// Slice
|
||||
callSites = callSites.slice(options.slice || 0);
|
||||
|
||||
// Modify CallSites
|
||||
if (options.extend) callSites = this.extend._modify(obj, callSites);
|
||||
if (options.filter) callSites = this.filter._modify(obj, callSites);
|
||||
|
||||
// Done
|
||||
return callSites;
|
||||
};
|
||||
|
||||
stackChain.prototype.originalCallSite = function (error) {
|
||||
error.stack;
|
||||
return error[originalCallSiteSymbol];
|
||||
};
|
||||
|
||||
stackChain.prototype.mutatedCallSite = function (error) {
|
||||
error.stack;
|
||||
return error[mutatedCallSiteSymbol];
|
||||
};
|
||||
|
||||
var chain = new stackChain();
|
||||
|
||||
function TraceModifier() {
|
||||
this._modifiers = [];
|
||||
}
|
||||
|
||||
TraceModifier.prototype._modify = function (error, frames) {
|
||||
for (var i = 0, l = this._modifiers.length; i < l; i++) {
|
||||
frames = this._modifiers[i](error, frames);
|
||||
}
|
||||
|
||||
return frames;
|
||||
};
|
||||
|
||||
TraceModifier.prototype.attach = function (modifier) {
|
||||
this._modifiers.push(modifier);
|
||||
};
|
||||
|
||||
TraceModifier.prototype.deattach = function (modifier) {
|
||||
var index = this._modifiers.indexOf(modifier);
|
||||
|
||||
if (index === -1) return false;
|
||||
|
||||
this._modifiers.splice(index, 1);
|
||||
return true;
|
||||
};
|
||||
|
||||
function StackFormater() {
|
||||
this._formater = defaultFormater;
|
||||
this._previous = undefined;
|
||||
}
|
||||
|
||||
StackFormater.prototype.replace = function (formater) {
|
||||
if (formater) {
|
||||
this._formater = formater;
|
||||
} else {
|
||||
this.restore();
|
||||
}
|
||||
};
|
||||
|
||||
StackFormater.prototype.restore = function () {
|
||||
this._formater = defaultFormater;
|
||||
this._previous = undefined;
|
||||
};
|
||||
|
||||
StackFormater.prototype._backup = function () {
|
||||
this._previous = this._formater;
|
||||
};
|
||||
|
||||
StackFormater.prototype._roolback = function () {
|
||||
if (this._previous === defaultFormater) {
|
||||
this.replace(undefined);
|
||||
} else {
|
||||
this.replace(this._previous);
|
||||
}
|
||||
|
||||
this._previous = undefined;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Set Error.prepareStackTrace thus allowing stack-chain
|
||||
// to take control of the Error().stack formating.
|
||||
//
|
||||
|
||||
// If there already is a custom stack formater, then set
|
||||
// that as the stack-chain formater.
|
||||
if (Error.prepareStackTrace) {
|
||||
chain.format.replace(Error.prepareStackTrace);
|
||||
}
|
||||
|
||||
var SHORTCIRCUIT_FORMATER = false;
|
||||
function prepareStackTrace(error, originalFrames) {
|
||||
if (SHORTCIRCUIT_CALLSITE) return originalFrames;
|
||||
if (SHORTCIRCUIT_FORMATER) return defaultFormater(error, originalFrames);
|
||||
|
||||
// Make a loss copy of originalFrames
|
||||
var frames = originalFrames.concat();
|
||||
|
||||
// extend frames
|
||||
frames = chain.extend._modify(error, frames);
|
||||
|
||||
// filter frames
|
||||
frames = chain.filter._modify(error, frames);
|
||||
|
||||
// reduce frames to match Error.stackTraceLimit
|
||||
frames = frames.slice(0, Error.stackTraceLimit);
|
||||
|
||||
// Set the callSite property
|
||||
// But only if it hasn't been explicitly set, otherwise
|
||||
// error.stack would have unintended side effects. Check also for
|
||||
// non-extensible/sealed objects, such as those from Google's Closure Library
|
||||
if (Object.isExtensible(error)) {
|
||||
error[originalCallSiteSymbol] = originalFrames;
|
||||
error[mutatedCallSiteSymbol] = frames;
|
||||
}
|
||||
|
||||
// format frames
|
||||
SHORTCIRCUIT_FORMATER = true;
|
||||
var format = chain.format._formater(error, frames);
|
||||
SHORTCIRCUIT_FORMATER = false;
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
// Replace the v8 stack trace creator
|
||||
Object.defineProperty(Error, 'prepareStackTrace', {
|
||||
'get': function () {
|
||||
return prepareStackTrace;
|
||||
},
|
||||
|
||||
'set': function (formater) {
|
||||
// If formater is prepareStackTrace it means that someone ran
|
||||
// var old = Error.prepareStackTrace;
|
||||
// Error.prepareStackTrace = custom
|
||||
// new Error().stack
|
||||
// Error.prepareStackTrace = old;
|
||||
// The effect of this, should be that the old behaviour is restored.
|
||||
if (formater === prepareStackTrace) {
|
||||
chain.format._roolback();
|
||||
}
|
||||
// Error.prepareStackTrace was set, this means that someone is
|
||||
// trying to take control of the Error().stack format. Make
|
||||
// them belive they succeeded by setting them up as the stack-chain
|
||||
// formater.
|
||||
else {
|
||||
chain.format._backup();
|
||||
chain.format.replace(formater);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = chain;
|
44
node_modules/stack-chain/test/produce.js
generated
vendored
Normal file
44
node_modules/stack-chain/test/produce.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
// Produces an error with `level` deept in the call stack
|
||||
exports.deepStack = function deepStack(curr, top, callback) {
|
||||
if (curr === top) {
|
||||
callback();
|
||||
} else {
|
||||
deepStack(curr + 1, top, callback);
|
||||
}
|
||||
};
|
||||
|
||||
exports.real = function produceError(level) {
|
||||
var stack;
|
||||
var limit = Error.stackTraceLimit;
|
||||
|
||||
exports.deepStack(0, level, function () {
|
||||
Error.stackTraceLimit = level;
|
||||
|
||||
var error = new Error('trace');
|
||||
error.test = true;
|
||||
stack = error.stack;
|
||||
|
||||
Error.stackTraceLimit = limit;
|
||||
});
|
||||
|
||||
return stack || 'Error: trace';
|
||||
};
|
||||
|
||||
exports.fake = function(input) {
|
||||
var output = [];
|
||||
|
||||
for (var i = 0, l = input.length; i < l; i++) {
|
||||
output.push(input[i].replace('{where}', module.filename));
|
||||
}
|
||||
|
||||
return output.join('\n');
|
||||
};
|
||||
|
||||
exports.convert = function (callSites) {
|
||||
var lines = [];
|
||||
for (var i = 0; i < callSites.length; i++) {
|
||||
lines.push(" at " + callSites[i].toString());
|
||||
}
|
||||
return lines.join('\n');
|
||||
};
|
121
node_modules/stack-chain/test/simple/callSite-function.js
generated
vendored
Normal file
121
node_modules/stack-chain/test/simple/callSite-function.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
test("stack extend part", function (t) {
|
||||
var extend = function (error, frames) {
|
||||
frames.splice(1, 0, 'EXTEND', 'FILTER ME');
|
||||
return frames;
|
||||
};
|
||||
|
||||
var filter = function (error, frames) {
|
||||
return frames.filter(function (callSite) {
|
||||
return callSite !== 'FILTER ME';
|
||||
});
|
||||
};
|
||||
|
||||
var callSites = function (level, options) {
|
||||
var limit = Error.stackTraceLimit;
|
||||
var callSites;
|
||||
produce.deepStack(0, level, function () {
|
||||
Error.stackTraceLimit = level;
|
||||
callSites = chain.callSite(options);
|
||||
Error.stackTraceLimit = limit;
|
||||
});
|
||||
|
||||
return callSites.slice(1, Infinity);
|
||||
};
|
||||
|
||||
t.test("callSite method matches simple case property length", function (t) {
|
||||
var method = chain.callSite();
|
||||
var propery = chain.originalCallSite(new Error());
|
||||
t.strictEqual(method.length, propery.length);
|
||||
|
||||
// The other stuff still works
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("pretest: toString of callSites array", function (t) {
|
||||
t.equal(produce.convert(callSites(3)), produce.fake([
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("callSite with extend", function (t) {
|
||||
chain.extend.attach(extend);
|
||||
var textA = produce.convert(callSites(3, { extend: true }));
|
||||
var textB = produce.convert(callSites(3));
|
||||
chain.extend.deattach(extend);
|
||||
|
||||
t.equal(textA, produce.fake([
|
||||
' at EXTEND',
|
||||
' at FILTER ME',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.equal(textB, produce.fake([
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("callSite with extend and filter", function (t) {
|
||||
chain.extend.attach(extend);
|
||||
chain.filter.attach(filter);
|
||||
var textA = produce.convert(callSites(3, { extend: true, filter: true }));
|
||||
var textB = produce.convert(callSites(3, { filter: true }));
|
||||
chain.filter.deattach(filter);
|
||||
chain.extend.deattach(extend);
|
||||
|
||||
t.equal(textA, produce.fake([
|
||||
' at EXTEND',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.equal(textB, produce.fake([
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("callSite with extend and filter and slice", function (t) {
|
||||
chain.extend.attach(extend);
|
||||
chain.filter.attach(filter);
|
||||
var textA = produce.convert(callSites(3, { extend: true, filter: true, slice: 1 }));
|
||||
var textB = produce.convert(callSites(3, { slice: 1 }));
|
||||
chain.filter.deattach(filter);
|
||||
chain.extend.deattach(extend);
|
||||
|
||||
t.equal(textA, produce.fake([
|
||||
' at EXTEND',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.equal(textB, produce.fake([
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
48
node_modules/stack-chain/test/simple/callSite-property.js
generated
vendored
Normal file
48
node_modules/stack-chain/test/simple/callSite-property.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
Error.stackTraceLimit = Infinity;
|
||||
|
||||
test("stack extend part", function (t) {
|
||||
var modify = function (text) {
|
||||
return function (error, frames) {
|
||||
if (error.test) {
|
||||
frames.push(text);
|
||||
}
|
||||
|
||||
return frames;
|
||||
};
|
||||
};
|
||||
|
||||
t.test("no extend modifier attached", function (t) {
|
||||
var error = new Error();
|
||||
error.test = error;
|
||||
|
||||
var original = chain.originalCallSite(error).length;
|
||||
var mutated = chain.mutatedCallSite(error).length;
|
||||
t.strictEqual(mutated, original);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("attach modifier", function (t) {
|
||||
var error = new Error();
|
||||
error.test = error;
|
||||
|
||||
var wonderLand = modify("wonder land");
|
||||
|
||||
chain.extend.attach(wonderLand);
|
||||
|
||||
var original = chain.originalCallSite(error).length;
|
||||
var mutated = chain.mutatedCallSite(error).length;
|
||||
t.strictEqual(mutated, original + 1);
|
||||
|
||||
chain.extend.deattach(wonderLand);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
86
node_modules/stack-chain/test/simple/conflict-format-delayed-circular.js
generated
vendored
Normal file
86
node_modules/stack-chain/test/simple/conflict-format-delayed-circular.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var defaultFormater = require('../../format.js');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
var chain = require('../../');
|
||||
|
||||
test("set Error.prepareStackTrace uses stack-chain formater", function (t) {
|
||||
// Save original formatter
|
||||
var restore = Error.prepareStackTrace;
|
||||
|
||||
// Overwrite formatter
|
||||
Error.prepareStackTrace = function (error, frames) {
|
||||
if (error.test) {
|
||||
Object.defineProperty(error, '__some_secret', {
|
||||
value: 'you can\'t compare pain.'
|
||||
});
|
||||
}
|
||||
|
||||
// Maintain .stack format
|
||||
return restore(error, frames);
|
||||
};
|
||||
|
||||
// Prope the error using custom prepareStackTrace
|
||||
var testError = new Error();
|
||||
testError.test = true;
|
||||
testError.stack;
|
||||
t.equal(testError.__some_secret, 'you can\'t compare pain.');
|
||||
|
||||
// Restore
|
||||
Error.prepareStackTrace = restore;
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("set Error.prepareStackTrace uses other formater", function (t) {
|
||||
// Another module sets up a formater
|
||||
Error.prepareStackTrace = function () {
|
||||
return 'custom';
|
||||
};
|
||||
|
||||
// Save original formatter
|
||||
var restore = Error.prepareStackTrace;
|
||||
|
||||
// Overwrite formatter
|
||||
Error.prepareStackTrace = function (error, frames) {
|
||||
if (error.test) {
|
||||
Object.defineProperty(error, '__some_secret', {
|
||||
value: 'you can\'t compare pain.'
|
||||
});
|
||||
}
|
||||
|
||||
// Maintain .stack format
|
||||
return restore(error, frames);
|
||||
};
|
||||
|
||||
// Prope the error using custom prepareStackTrace
|
||||
var testError = new Error();
|
||||
testError.test = true;
|
||||
testError.stack;
|
||||
t.equal(testError.__some_secret, 'you can\'t compare pain.');
|
||||
|
||||
// Restore
|
||||
Error.prepareStackTrace = restore;
|
||||
|
||||
t.equal(produce.real(3), 'custom');
|
||||
|
||||
// Perform an actual restore of the formater, to prevent test conflicts
|
||||
chain.format.restore();
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
112
node_modules/stack-chain/test/simple/conflict-format-delayed.js
generated
vendored
Normal file
112
node_modules/stack-chain/test/simple/conflict-format-delayed.js
generated
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var defaultFormater = require('../../format.js');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
var chain = require('../../');
|
||||
|
||||
// Set a formater after stack-chain is required
|
||||
function prepareStackTrace(error, frames) {
|
||||
if (error.test) {
|
||||
var lines = [];
|
||||
lines.push(error.toString());
|
||||
|
||||
for (var i = 0, l = frames.length; i < l; i++) {
|
||||
lines.push(frames[i].getFunctionName());
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
return defaultFormater(error, frames);
|
||||
}
|
||||
|
||||
test("set Error.prepareStackTrace after require", function (t) {
|
||||
t.test("set prepareStackTrace", function (t) {
|
||||
Error.prepareStackTrace = prepareStackTrace;
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("default formatter replaced", function (t) {
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
'',
|
||||
'deepStack',
|
||||
'deepStack'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("restore default formater", function (t) {
|
||||
chain.format.restore();
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("set Error.prepareStackTrace after require to undefined", function (t) {
|
||||
t.test("set prepareStackTrace", function (t) {
|
||||
Error.prepareStackTrace = prepareStackTrace;
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("default formatter replaced", function (t) {
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
'',
|
||||
'deepStack',
|
||||
'deepStack'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("restore default formater", function (t) {
|
||||
Error.prepareStackTrace = undefined;
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test("set Error.prepareStackTrace after require to itself", function (t) {
|
||||
t.test("default formatter replaced", function (t) {
|
||||
var old = Error.prepareStackTrace;
|
||||
|
||||
Error.prepareStackTrace = function () {
|
||||
return 'custom';
|
||||
};
|
||||
t.equal(new Error().stack, 'custom');
|
||||
|
||||
Error.prepareStackTrace = old;
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
50
node_modules/stack-chain/test/simple/conflict-format-existing.js
generated
vendored
Normal file
50
node_modules/stack-chain/test/simple/conflict-format-existing.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var defaultFormater = require('../../format.js');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
// Set a formater before stack-chain is required
|
||||
Error.prepareStackTrace = function (error, frames) {
|
||||
if (error.test) {
|
||||
var lines = [];
|
||||
lines.push(error.toString());
|
||||
|
||||
for (var i = 0, l = frames.length; i < l; i++) {
|
||||
lines.push(frames[i].getFunctionName());
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
return defaultFormater(error, frames);
|
||||
};
|
||||
|
||||
var chain = require('../../');
|
||||
|
||||
test("set Error.prepareStackTrace before require", function (t) {
|
||||
t.test("default formatter replaced", function (t) {
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
'',
|
||||
'deepStack',
|
||||
'deepStack'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("restore default formater", function (t) {
|
||||
chain.format.restore();
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
8
node_modules/stack-chain/test/simple/conflict-version-first.js
generated
vendored
Normal file
8
node_modules/stack-chain/test/simple/conflict-version-first.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
|
||||
test("no other copy", function (t) {
|
||||
t.strictEqual(global._stackChain, chain);
|
||||
t.end();
|
||||
});
|
10
node_modules/stack-chain/test/simple/conflict-version-match.js
generated
vendored
Normal file
10
node_modules/stack-chain/test/simple/conflict-version-match.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
|
||||
var first = global._stackChain = { version: require('../../package.json').version };
|
||||
var chain = require('../../');
|
||||
|
||||
test("same version but copies", function (t) {
|
||||
t.strictEqual(chain, first);
|
||||
t.end();
|
||||
});
|
13
node_modules/stack-chain/test/simple/conflict-version-mismatch.js
generated
vendored
Normal file
13
node_modules/stack-chain/test/simple/conflict-version-mismatch.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
|
||||
global._stackChain = { version: "unlikely" };
|
||||
|
||||
test("diffrent version but copies", function (t) {
|
||||
try {
|
||||
require('../../');
|
||||
} catch (e) {
|
||||
t.equal(e.message, 'Conflicting version of stack-chain found');
|
||||
t.end();
|
||||
}
|
||||
});
|
84
node_modules/stack-chain/test/simple/extend.js
generated
vendored
Normal file
84
node_modules/stack-chain/test/simple/extend.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
test("stack extend part", function (t) {
|
||||
var modify = function (text) {
|
||||
return function (error, frames) {
|
||||
if (error.test) {
|
||||
frames.splice(1, 0, text);
|
||||
}
|
||||
|
||||
return frames;
|
||||
};
|
||||
};
|
||||
|
||||
t.test("no extend modifier attached", function (t) {
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("attach modifier", function (t) {
|
||||
var wonderLand = modify("wonder land");
|
||||
|
||||
chain.extend.attach(wonderLand);
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at wonder land',
|
||||
' at deepStack ({where}:5:5)'
|
||||
]));
|
||||
|
||||
chain.extend.deattach(wonderLand);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("deattach modifier", function (t) {
|
||||
var wonderLand = modify("wonder land");
|
||||
|
||||
chain.extend.attach(wonderLand);
|
||||
t.equal(chain.extend.deattach(wonderLand), true);
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.equal(chain.extend.deattach(wonderLand), false);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("execution order", function (t) {
|
||||
var wonderLand = modify("wonder land");
|
||||
var outerSpace = modify("outer space");
|
||||
|
||||
chain.extend.attach(wonderLand);
|
||||
chain.extend.attach(outerSpace);
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at outer space',
|
||||
' at wonder land'
|
||||
]));
|
||||
|
||||
chain.extend.deattach(wonderLand);
|
||||
chain.extend.deattach(outerSpace);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
72
node_modules/stack-chain/test/simple/filter.js
generated
vendored
Normal file
72
node_modules/stack-chain/test/simple/filter.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
test("stack filter part", function (t) {
|
||||
var filter = function (error, frames) {
|
||||
if (error.test) {
|
||||
frames.splice(0, 1);
|
||||
}
|
||||
|
||||
return frames;
|
||||
};
|
||||
|
||||
t.test("no extend modifier attached", function (t) {
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("attach modifier", function (t) {
|
||||
chain.extend.attach(filter);
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
chain.extend.deattach(filter);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("deattach modifier", function (t) {
|
||||
chain.extend.attach(filter);
|
||||
t.equal(chain.extend.deattach(filter), true);
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.equal(chain.extend.deattach(filter), false);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("execution order", function (t) {
|
||||
chain.extend.attach(filter);
|
||||
chain.extend.attach(filter);
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
chain.extend.deattach(filter);
|
||||
chain.extend.deattach(filter);
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
64
node_modules/stack-chain/test/simple/format-replace.js
generated
vendored
Normal file
64
node_modules/stack-chain/test/simple/format-replace.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
var defaultFormater = require('../../format.js');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
test("stack format part", function (t) {
|
||||
var format = function (error, frames) {
|
||||
if (error.test) {
|
||||
var lines = [];
|
||||
lines.push(error.toString());
|
||||
|
||||
for (var i = 0, l = frames.length; i < l; i++) {
|
||||
lines.push(frames[i].getFunctionName());
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
return defaultFormater(error, frames);
|
||||
};
|
||||
|
||||
t.test("no formatter set", function (t) {
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("default formatter replaced", function (t) {
|
||||
chain.format.replace(format);
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
'',
|
||||
'deepStack',
|
||||
'deepStack'
|
||||
]));
|
||||
|
||||
chain.format.restore();
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.test("restore default formater", function (t) {
|
||||
chain.format.replace(format);
|
||||
chain.format.restore();
|
||||
|
||||
t.equal(produce.real(3), produce.fake([
|
||||
'Error: trace',
|
||||
' at {where}:18:17',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
19
node_modules/stack-chain/test/simple/format-tostring-non-generic.js
generated
vendored
Normal file
19
node_modules/stack-chain/test/simple/format-tostring-non-generic.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
// See issue https://github.com/AndreasMadsen/stack-chain/issues/12 for
|
||||
// a detailed explaination.
|
||||
|
||||
test("formatter works for non-generic (non-safe) toString", function (t) {
|
||||
var base = function () {}
|
||||
base.toString = base.toString // sets base.toString to base[[proto]].toString
|
||||
Object.setPrototypeOf(base, {}); // sets base[[proto]] = {}
|
||||
|
||||
var error = Object.create(base); // wrap base using prototype chain
|
||||
Error.captureStackTrace(error); // prepear error.stack
|
||||
|
||||
t.equal(error.stack.split('\n').length, 11);
|
||||
t.end();
|
||||
});
|
29
node_modules/stack-chain/test/simple/non-extensible-errors.js
generated
vendored
Normal file
29
node_modules/stack-chain/test/simple/non-extensible-errors.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
|
||||
test("non extensible Error objects don't throw", function(t) {
|
||||
var error = new Error("don't extend me");
|
||||
Object.preventExtensions(error)
|
||||
t.doesNotThrow(function() {
|
||||
error.stack;
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('stack is correct on non extensible error object', function (t) {
|
||||
var error = new Error("don't extend me");
|
||||
Object.preventExtensions(error);
|
||||
|
||||
chain.format.replace(function () {
|
||||
return 'good';
|
||||
});
|
||||
|
||||
try {
|
||||
t.equal(error.stack, 'good');
|
||||
} catch (e) { t.ifError(e); }
|
||||
|
||||
chain.format.restore();
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
40
node_modules/stack-chain/test/simple/order.js
generated
vendored
Normal file
40
node_modules/stack-chain/test/simple/order.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var chain = require('../../');
|
||||
var produce = require('../produce.js');
|
||||
|
||||
test("modifier execution order", function (t) {
|
||||
var filter = function (error, frames) {
|
||||
if (error.test) {
|
||||
frames.splice(0, 1);
|
||||
}
|
||||
|
||||
return frames;
|
||||
};
|
||||
|
||||
var modify = function (error, frames) {
|
||||
if (error.test) {
|
||||
frames.splice(1, 0, "wonder land");
|
||||
}
|
||||
|
||||
return frames;
|
||||
};
|
||||
|
||||
chain.filter.attach(filter);
|
||||
chain.extend.attach(modify);
|
||||
chain.extend.attach(modify);
|
||||
|
||||
t.equal(produce.real(4), produce.fake([
|
||||
'Error: trace',
|
||||
' at wonder land',
|
||||
' at wonder land',
|
||||
' at deepStack ({where}:5:5)',
|
||||
' at deepStack ({where}:7:5)'
|
||||
]));
|
||||
|
||||
chain.filter.deattach(filter);
|
||||
chain.extend.deattach(modify);
|
||||
chain.extend.deattach(modify);
|
||||
|
||||
t.end();
|
||||
});
|
12
node_modules/stack-chain/test/simple/uglify.js
generated
vendored
Normal file
12
node_modules/stack-chain/test/simple/uglify.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
var test = require("tap").test;
|
||||
var uglify = require("uglify-js");
|
||||
var path = require("path");
|
||||
|
||||
test("can be uglified", function (t) {
|
||||
var files = ['format.js', 'index.js', 'stack-chain.js'].map(function (filename) {
|
||||
return path.resolve(__dirname, '../../' + filename);
|
||||
});
|
||||
uglify.minify(files);
|
||||
t.end()
|
||||
});
|
Reference in New Issue
Block a user