Initial commit
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
docs/
|
||||
test/
|
||||
build/
|
||||
components/
|
||||
support/
|
||||
coverage.html
|
||||
component.json
|
||||
lib-cov
|
||||
.travis.yml
|
||||
Makefile
|
||||
*.swp
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
1.0.1 / 2015-03-04
|
||||
==================
|
||||
|
||||
* Merge pull request #2 from simonzack/master
|
||||
* fixes `.stack` on firefox
|
||||
|
||||
1.0.0 / 2013-06-08
|
||||
==================
|
||||
|
||||
* readme: change travis and component urls
|
||||
* refactor: [*] prepare for move to chaijs gh org
|
||||
|
||||
0.1.0 / 2013-04-07
|
||||
==================
|
||||
|
||||
* test: use vanilla test runner/assert
|
||||
* pgk: remove unused deps
|
||||
* lib: implement
|
||||
* "Initial commit"
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
# AssertionError [](https://travis-ci.org/chaijs/assertion-error)
|
||||
|
||||
> Error constructor for test and validation frameworks that implements standardized AssertionError specification.
|
||||
|
||||
## Installation
|
||||
|
||||
### Node.js
|
||||
|
||||
`assertion-error` is available on [npm](http://npmjs.org).
|
||||
|
||||
$ npm install assertion-error
|
||||
|
||||
### Component
|
||||
|
||||
`assertion-error` is available as a [component](https://github.com/component/component).
|
||||
|
||||
$ component install chaijs/assertion-error
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Jake Luer <jake@qualiancy.com> (http://qualiancy.com)
|
||||
|
||||
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.
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*!
|
||||
* assertion-error
|
||||
* Copyright(c) 2013 Jake Luer <jake@qualiancy.com>
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Return a function that will copy properties from
|
||||
* one object to another excluding any originally
|
||||
* listed. Returned function will create a new `{}`.
|
||||
*
|
||||
* @param {String} excluded properties ...
|
||||
* @return {Function}
|
||||
*/
|
||||
|
||||
function exclude () {
|
||||
var excludes = [].slice.call(arguments);
|
||||
|
||||
function excludeProps (res, obj) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
if (!~excludes.indexOf(key)) res[key] = obj[key];
|
||||
});
|
||||
}
|
||||
|
||||
return function extendExclude () {
|
||||
var args = [].slice.call(arguments)
|
||||
, i = 0
|
||||
, res = {};
|
||||
|
||||
for (; i < args.length; i++) {
|
||||
excludeProps(res, args[i]);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
};
|
||||
|
||||
/*!
|
||||
* Primary Exports
|
||||
*/
|
||||
|
||||
module.exports = AssertionError;
|
||||
|
||||
/**
|
||||
* ### AssertionError
|
||||
*
|
||||
* An extension of the JavaScript `Error` constructor for
|
||||
* assertion and validation scenarios.
|
||||
*
|
||||
* @param {String} message
|
||||
* @param {Object} properties to include (optional)
|
||||
* @param {callee} start stack function (optional)
|
||||
*/
|
||||
|
||||
function AssertionError (message, _props, ssf) {
|
||||
var extend = exclude('name', 'message', 'stack', 'constructor', 'toJSON')
|
||||
, props = extend(_props || {});
|
||||
|
||||
// default values
|
||||
this.message = message || 'Unspecified AssertionError';
|
||||
this.showDiff = false;
|
||||
|
||||
// copy from properties
|
||||
for (var key in props) {
|
||||
this[key] = props[key];
|
||||
}
|
||||
|
||||
// capture stack trace
|
||||
ssf = ssf || arguments.callee;
|
||||
if (ssf && Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, ssf);
|
||||
} else {
|
||||
try {
|
||||
throw new Error();
|
||||
} catch(e) {
|
||||
this.stack = e.stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* Inherit from Error.prototype
|
||||
*/
|
||||
|
||||
AssertionError.prototype = Object.create(Error.prototype);
|
||||
|
||||
/*!
|
||||
* Statically set name
|
||||
*/
|
||||
|
||||
AssertionError.prototype.name = 'AssertionError';
|
||||
|
||||
/*!
|
||||
* Ensure correct constructor
|
||||
*/
|
||||
|
||||
AssertionError.prototype.constructor = AssertionError;
|
||||
|
||||
/**
|
||||
* Allow errors to be converted to JSON for static transfer.
|
||||
*
|
||||
* @param {Boolean} include stack (default: `true`)
|
||||
* @return {Object} object that can be `JSON.stringify`
|
||||
*/
|
||||
|
||||
AssertionError.prototype.toJSON = function (stack) {
|
||||
var extend = exclude('constructor', 'toJSON', 'stack')
|
||||
, props = extend({ name: this.name }, this);
|
||||
|
||||
// include stack if exists and not turned off
|
||||
if (false !== stack && this.stack) {
|
||||
props.stack = this.stack;
|
||||
}
|
||||
|
||||
return props;
|
||||
};
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"assertion-error@^1.0.1",
|
||||
"/home/xor/shared_vm/git/node-sunwell/node_modules/chai"
|
||||
]
|
||||
],
|
||||
"_from": "assertion-error@>=1.0.1 <2.0.0",
|
||||
"_id": "assertion-error@1.0.2",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/assertion-error",
|
||||
"_nodeVersion": "5.7.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-16-east.internal.npmjs.com",
|
||||
"tmp": "tmp/assertion-error-1.0.2.tgz_1465237527264_0.8082898685242981"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "chaijs@keithcirkel.co.uk",
|
||||
"name": "chaijs"
|
||||
},
|
||||
"_npmVersion": "3.8.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "assertion-error",
|
||||
"raw": "assertion-error@^1.0.1",
|
||||
"rawSpec": "^1.0.1",
|
||||
"scope": null,
|
||||
"spec": ">=1.0.1 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/chai"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz",
|
||||
"_shasum": "13ca515d86206da0bac66e834dd397d87581094c",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "assertion-error@^1.0.1",
|
||||
"_where": "/home/xor/shared_vm/git/node-sunwell/node_modules/chai",
|
||||
"author": {
|
||||
"email": "jake@qualiancy.com",
|
||||
"name": "Jake Luer",
|
||||
"url": "http://qualiancy.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/chaijs/assertion-error/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Error constructor for test and validation frameworks that implements standardized AssertionError specification.",
|
||||
"devDependencies": {
|
||||
"component": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "13ca515d86206da0bac66e834dd397d87581094c",
|
||||
"tarball": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"gitHead": "b36f593951c1487fa33747c9911025734923f28c",
|
||||
"homepage": "https://github.com/chaijs/assertion-error#readme",
|
||||
"keywords": [
|
||||
"assertion",
|
||||
"assertion-error",
|
||||
"test"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./index",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "chaijs",
|
||||
"email": "chaijs@keithcirkel.co.uk"
|
||||
}
|
||||
],
|
||||
"name": "assertion-error",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/chaijs/assertion-error.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.0.2"
|
||||
}
|
||||
Reference in New Issue
Block a user