sdfsdfs
This commit is contained in:
12
node_modules/assert/.github/FUNDING.yml
generated
vendored
Normal file
12
node_modules/assert/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/assert
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
10
node_modules/assert/.github/SECURITY.md
generated
vendored
Normal file
10
node_modules/assert/.github/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
Only the latest major version is supported at any given time.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
30
node_modules/assert/.travis.yml
generated
vendored
Normal file
30
node_modules/assert/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
language: node_js
|
||||
before_install:
|
||||
- nvm install-latest-npm
|
||||
matrix:
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env: TASK=test-node
|
||||
- node_js: '0.10'
|
||||
env: TASK=test-node
|
||||
- node_js: '0.11'
|
||||
env: TASK=test-node
|
||||
- node_js: '0.12'
|
||||
env: TASK=test-node
|
||||
- node_js: 1
|
||||
env: TASK=test-node
|
||||
- node_js: 2
|
||||
env: TASK=test-node
|
||||
- node_js: 3
|
||||
env: TASK=test-node
|
||||
- node_js: 4
|
||||
env: TASK=test-node
|
||||
- node_js: 5
|
||||
env: TASK=test-node
|
||||
- node_js: '0.10'
|
||||
env: TASK=test-browser
|
||||
script: "npm run $TASK"
|
||||
env:
|
||||
global:
|
||||
- secure: qThuKBZQtkooAvzaYldECGNqvKGPRTnXx62IVyhSbFlsCY1VCmjhLldhyPDiZQ3JqL1XvSkK8OMDupiHqZnNE0nGijoO4M/kaEdjBB+jpjg3f8I6te2SNU935SbkfY9KHAaFXMZwdcq7Fk932AxWEu+FMSDM+080wNKpEATXDe4=
|
||||
- secure: O/scKjHLRcPN5ILV5qsSkksQ7qcZQdHWEUUPItmj/4+vmCc28bHpicoUxXG5A96iHvkBbdmky/nGCg464ZaNLk68m6hfEMDAR3J6mhM2Pf5C4QI/LlFlR1fob9sQ8lztwSGOItwdK8Rfrgb30RRVV71f6FxnaJ6PKMuMNT5S1AQ=
|
13
node_modules/assert/.zuul.yml
generated
vendored
Normal file
13
node_modules/assert/.zuul.yml
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
ui: mocha-qunit
|
||||
tunnel: ngrok
|
||||
browsers:
|
||||
- name: chrome
|
||||
version: latest
|
||||
- name: firefox
|
||||
version: latest
|
||||
- name: safari
|
||||
version: latest
|
||||
- name: ie
|
||||
version: 9..latest
|
||||
- name: microsoftedge
|
||||
version: latest
|
11
node_modules/assert/CHANGELOG.md
generated
vendored
Normal file
11
node_modules/assert/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# assert change log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 1.5.1
|
||||
* [Deps] switch to `object.assign`, and unpin `util`
|
||||
|
||||
## 1.5.0
|
||||
* Add strict mode APIs. ([@lukechilds](https://github.com/lukechilds) in [#41](https://github.com/browserify/commonjs-assert/pull/41))
|
18
node_modules/assert/LICENSE
generated
vendored
Normal file
18
node_modules/assert/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
105
node_modules/assert/README.md
generated
vendored
Normal file
105
node_modules/assert/README.md
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
# assert
|
||||
|
||||
[](https://travis-ci.org/browserify/commonjs-assert)
|
||||
|
||||
This module is used for writing unit tests for your applications, you can access it with `require('assert')`.
|
||||
|
||||
It aims to be fully compatibe with the [node.js assert module](http://nodejs.org/api/assert.html), same API and same behavior, just adding support for web browsers.
|
||||
The API and code may contain traces of the [CommonJS Unit Testing 1.0 spec](http://wiki.commonjs.org/wiki/Unit_Testing/1.0) which they were based on, but both have evolved significantly since then.
|
||||
|
||||
A `strict` and a `legacy` mode exist, while it is recommended to only use `strict mode`.
|
||||
|
||||
## Strict mode
|
||||
|
||||
When using the `strict mode`, any `assert` function will use the equality used in the strict function mode. So `assert.deepEqual()` will, for example, work the same as `assert.deepStrictEqual()`.
|
||||
|
||||
It can be accessed using:
|
||||
|
||||
```js
|
||||
const assert = require('assert').strict;
|
||||
```
|
||||
|
||||
## Legacy mode
|
||||
|
||||
> Deprecated: Use strict mode instead.
|
||||
|
||||
When accessing `assert` directly instead of using the `strict` property, the
|
||||
[Abstract Equality Comparison](https://tc39.github.io/ecma262/#sec-abstract-equality-comparison) will be used for any function without a
|
||||
"strict" in its name (e.g. `assert.deepEqual()`).
|
||||
|
||||
It can be accessed using:
|
||||
|
||||
```js
|
||||
const assert = require('assert');
|
||||
```
|
||||
|
||||
It is recommended to use the `strict mode` instead as the Abstract Equality Comparison can often have surprising results. Especially
|
||||
in case of `assert.deepEqual()` as the used comparison rules there are very lax.
|
||||
|
||||
E.g.
|
||||
|
||||
```js
|
||||
// WARNING: This does not throw an AssertionError!
|
||||
assert.deepEqual(/a/gi, new Date());
|
||||
```
|
||||
|
||||
|
||||
## assert.fail(actual, expected, message, operator)
|
||||
Throws an exception that displays the values for actual and expected separated by the provided operator.
|
||||
|
||||
## assert(value, message), assert.ok(value, [message])
|
||||
Tests if value is truthy, it is equivalent to assert.equal(true, !!value, message);
|
||||
|
||||
## assert.equal(actual, expected, [message])
|
||||
Tests shallow, coercive equality with the equal comparison operator ( == ).
|
||||
|
||||
## assert.notEqual(actual, expected, [message])
|
||||
Tests shallow, coercive non-equality with the not equal comparison operator ( != ).
|
||||
|
||||
## assert.deepEqual(actual, expected, [message])
|
||||
Tests for deep equality.
|
||||
|
||||
## assert.deepStrictEqual(actual, expected, [message])
|
||||
Tests for deep equality, as determined by the strict equality operator ( === )
|
||||
|
||||
## assert.notDeepEqual(actual, expected, [message])
|
||||
Tests for any deep inequality.
|
||||
|
||||
## assert.strictEqual(actual, expected, [message])
|
||||
Tests strict equality, as determined by the strict equality operator ( === )
|
||||
|
||||
## assert.notStrictEqual(actual, expected, [message])
|
||||
Tests strict non-equality, as determined by the strict not equal operator ( !== )
|
||||
|
||||
## assert.throws(block, [error], [message])
|
||||
Expects block to throw an error. error can be constructor, regexp or validation function.
|
||||
|
||||
Validate instanceof using constructor:
|
||||
|
||||
```javascript
|
||||
assert.throws(function() { throw new Error("Wrong value"); }, Error);
|
||||
```
|
||||
|
||||
Validate error message using RegExp:
|
||||
|
||||
```javascript
|
||||
assert.throws(function() { throw new Error("Wrong value"); }, /value/);
|
||||
```
|
||||
|
||||
Custom error validation:
|
||||
|
||||
```javascript
|
||||
assert.throws(function() {
|
||||
throw new Error("Wrong value");
|
||||
}, function(err) {
|
||||
if ( (err instanceof Error) && /value/.test(err) ) {
|
||||
return true;
|
||||
}
|
||||
}, "unexpected error");
|
||||
```
|
||||
|
||||
## assert.doesNotThrow(block, [message])
|
||||
Expects block not to throw an error, see assert.throws for details.
|
||||
|
||||
## assert.ifError(value)
|
||||
Tests if value is not a false value, throws if it is a true value. Useful when testing the first argument, error in callbacks.
|
506
node_modules/assert/assert.js
generated
vendored
Normal file
506
node_modules/assert/assert.js
generated
vendored
Normal file
@@ -0,0 +1,506 @@
|
||||
'use strict';
|
||||
|
||||
var objectAssign = require('object.assign/polyfill')();
|
||||
|
||||
// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
|
||||
// original notice:
|
||||
|
||||
/*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
||||
* @license MIT
|
||||
*/
|
||||
function compare(a, b) {
|
||||
if (a === b) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var x = a.length;
|
||||
var y = b.length;
|
||||
|
||||
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
||||
if (a[i] !== b[i]) {
|
||||
x = a[i];
|
||||
y = b[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (x < y) {
|
||||
return -1;
|
||||
}
|
||||
if (y < x) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function isBuffer(b) {
|
||||
if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
|
||||
return global.Buffer.isBuffer(b);
|
||||
}
|
||||
return !!(b != null && b._isBuffer);
|
||||
}
|
||||
|
||||
// based on node assert, original notice:
|
||||
// NB: The URL to the CommonJS spec is kept just for tradition.
|
||||
// node-assert has evolved a lot since then, both in API and behavior.
|
||||
|
||||
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
|
||||
//
|
||||
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
|
||||
//
|
||||
// Originally from narwhal.js (http://narwhaljs.org)
|
||||
// Copyright (c) 2009 Thomas Robinson <280north.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 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.
|
||||
|
||||
var util = require('util/');
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
var pSlice = Array.prototype.slice;
|
||||
var functionsHaveNames = (function () {
|
||||
return function foo() {}.name === 'foo';
|
||||
}());
|
||||
function pToString (obj) {
|
||||
return Object.prototype.toString.call(obj);
|
||||
}
|
||||
function isView(arrbuf) {
|
||||
if (isBuffer(arrbuf)) {
|
||||
return false;
|
||||
}
|
||||
if (typeof global.ArrayBuffer !== 'function') {
|
||||
return false;
|
||||
}
|
||||
if (typeof ArrayBuffer.isView === 'function') {
|
||||
return ArrayBuffer.isView(arrbuf);
|
||||
}
|
||||
if (!arrbuf) {
|
||||
return false;
|
||||
}
|
||||
if (arrbuf instanceof DataView) {
|
||||
return true;
|
||||
}
|
||||
if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// 1. The assert module provides functions that throw
|
||||
// AssertionError's when particular conditions are not met. The
|
||||
// assert module must conform to the following interface.
|
||||
|
||||
var assert = module.exports = ok;
|
||||
|
||||
// 2. The AssertionError is defined in assert.
|
||||
// new assert.AssertionError({ message: message,
|
||||
// actual: actual,
|
||||
// expected: expected })
|
||||
|
||||
var regex = /\s*function\s+([^\(\s]*)\s*/;
|
||||
// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
|
||||
function getName(func) {
|
||||
if (!util.isFunction(func)) {
|
||||
return;
|
||||
}
|
||||
if (functionsHaveNames) {
|
||||
return func.name;
|
||||
}
|
||||
var str = func.toString();
|
||||
var match = str.match(regex);
|
||||
return match && match[1];
|
||||
}
|
||||
assert.AssertionError = function AssertionError(options) {
|
||||
this.name = 'AssertionError';
|
||||
this.actual = options.actual;
|
||||
this.expected = options.expected;
|
||||
this.operator = options.operator;
|
||||
if (options.message) {
|
||||
this.message = options.message;
|
||||
this.generatedMessage = false;
|
||||
} else {
|
||||
this.message = getMessage(this);
|
||||
this.generatedMessage = true;
|
||||
}
|
||||
var stackStartFunction = options.stackStartFunction || fail;
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, stackStartFunction);
|
||||
} else {
|
||||
// non v8 browsers so we can have a stacktrace
|
||||
var err = new Error();
|
||||
if (err.stack) {
|
||||
var out = err.stack;
|
||||
|
||||
// try to strip useless frames
|
||||
var fn_name = getName(stackStartFunction);
|
||||
var idx = out.indexOf('\n' + fn_name);
|
||||
if (idx >= 0) {
|
||||
// once we have located the function frame
|
||||
// we need to strip out everything before it (and its line)
|
||||
var next_line = out.indexOf('\n', idx + 1);
|
||||
out = out.substring(next_line + 1);
|
||||
}
|
||||
|
||||
this.stack = out;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// assert.AssertionError instanceof Error
|
||||
util.inherits(assert.AssertionError, Error);
|
||||
|
||||
function truncate(s, n) {
|
||||
if (typeof s === 'string') {
|
||||
return s.length < n ? s : s.slice(0, n);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
function inspect(something) {
|
||||
if (functionsHaveNames || !util.isFunction(something)) {
|
||||
return util.inspect(something);
|
||||
}
|
||||
var rawname = getName(something);
|
||||
var name = rawname ? ': ' + rawname : '';
|
||||
return '[Function' + name + ']';
|
||||
}
|
||||
function getMessage(self) {
|
||||
return truncate(inspect(self.actual), 128) + ' ' +
|
||||
self.operator + ' ' +
|
||||
truncate(inspect(self.expected), 128);
|
||||
}
|
||||
|
||||
// At present only the three keys mentioned above are used and
|
||||
// understood by the spec. Implementations or sub modules can pass
|
||||
// other keys to the AssertionError's constructor - they will be
|
||||
// ignored.
|
||||
|
||||
// 3. All of the following functions must throw an AssertionError
|
||||
// when a corresponding condition is not met, with a message that
|
||||
// may be undefined if not provided. All assertion methods provide
|
||||
// both the actual and expected values to the assertion error for
|
||||
// display purposes.
|
||||
|
||||
function fail(actual, expected, message, operator, stackStartFunction) {
|
||||
throw new assert.AssertionError({
|
||||
message: message,
|
||||
actual: actual,
|
||||
expected: expected,
|
||||
operator: operator,
|
||||
stackStartFunction: stackStartFunction
|
||||
});
|
||||
}
|
||||
|
||||
// EXTENSION! allows for well behaved errors defined elsewhere.
|
||||
assert.fail = fail;
|
||||
|
||||
// 4. Pure assertion tests whether a value is truthy, as determined
|
||||
// by !!guard.
|
||||
// assert.ok(guard, message_opt);
|
||||
// This statement is equivalent to assert.equal(true, !!guard,
|
||||
// message_opt);. To test strictly for the value true, use
|
||||
// assert.strictEqual(true, guard, message_opt);.
|
||||
|
||||
function ok(value, message) {
|
||||
if (!value) fail(value, true, message, '==', assert.ok);
|
||||
}
|
||||
assert.ok = ok;
|
||||
|
||||
// 5. The equality assertion tests shallow, coercive equality with
|
||||
// ==.
|
||||
// assert.equal(actual, expected, message_opt);
|
||||
|
||||
assert.equal = function equal(actual, expected, message) {
|
||||
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
|
||||
};
|
||||
|
||||
// 6. The non-equality assertion tests for whether two objects are not equal
|
||||
// with != assert.notEqual(actual, expected, message_opt);
|
||||
|
||||
assert.notEqual = function notEqual(actual, expected, message) {
|
||||
if (actual == expected) {
|
||||
fail(actual, expected, message, '!=', assert.notEqual);
|
||||
}
|
||||
};
|
||||
|
||||
// 7. The equivalence assertion tests a deep equality relation.
|
||||
// assert.deepEqual(actual, expected, message_opt);
|
||||
|
||||
assert.deepEqual = function deepEqual(actual, expected, message) {
|
||||
if (!_deepEqual(actual, expected, false)) {
|
||||
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
|
||||
}
|
||||
};
|
||||
|
||||
assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
|
||||
if (!_deepEqual(actual, expected, true)) {
|
||||
fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
|
||||
}
|
||||
};
|
||||
|
||||
function _deepEqual(actual, expected, strict, memos) {
|
||||
// 7.1. All identical values are equivalent, as determined by ===.
|
||||
if (actual === expected) {
|
||||
return true;
|
||||
} else if (isBuffer(actual) && isBuffer(expected)) {
|
||||
return compare(actual, expected) === 0;
|
||||
|
||||
// 7.2. If the expected value is a Date object, the actual value is
|
||||
// equivalent if it is also a Date object that refers to the same time.
|
||||
} else if (util.isDate(actual) && util.isDate(expected)) {
|
||||
return actual.getTime() === expected.getTime();
|
||||
|
||||
// 7.3 If the expected value is a RegExp object, the actual value is
|
||||
// equivalent if it is also a RegExp object with the same source and
|
||||
// properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
|
||||
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
|
||||
return actual.source === expected.source &&
|
||||
actual.global === expected.global &&
|
||||
actual.multiline === expected.multiline &&
|
||||
actual.lastIndex === expected.lastIndex &&
|
||||
actual.ignoreCase === expected.ignoreCase;
|
||||
|
||||
// 7.4. Other pairs that do not both pass typeof value == 'object',
|
||||
// equivalence is determined by ==.
|
||||
} else if ((actual === null || typeof actual !== 'object') &&
|
||||
(expected === null || typeof expected !== 'object')) {
|
||||
return strict ? actual === expected : actual == expected;
|
||||
|
||||
// If both values are instances of typed arrays, wrap their underlying
|
||||
// ArrayBuffers in a Buffer each to increase performance
|
||||
// This optimization requires the arrays to have the same type as checked by
|
||||
// Object.prototype.toString (aka pToString). Never perform binary
|
||||
// comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
|
||||
// bit patterns are not identical.
|
||||
} else if (isView(actual) && isView(expected) &&
|
||||
pToString(actual) === pToString(expected) &&
|
||||
!(actual instanceof Float32Array ||
|
||||
actual instanceof Float64Array)) {
|
||||
return compare(new Uint8Array(actual.buffer),
|
||||
new Uint8Array(expected.buffer)) === 0;
|
||||
|
||||
// 7.5 For all other Object pairs, including Array objects, equivalence is
|
||||
// determined by having the same number of owned properties (as verified
|
||||
// with Object.prototype.hasOwnProperty.call), the same set of keys
|
||||
// (although not necessarily the same order), equivalent values for every
|
||||
// corresponding key, and an identical 'prototype' property. Note: this
|
||||
// accounts for both named and indexed properties on Arrays.
|
||||
} else if (isBuffer(actual) !== isBuffer(expected)) {
|
||||
return false;
|
||||
} else {
|
||||
memos = memos || {actual: [], expected: []};
|
||||
|
||||
var actualIndex = memos.actual.indexOf(actual);
|
||||
if (actualIndex !== -1) {
|
||||
if (actualIndex === memos.expected.indexOf(expected)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
memos.actual.push(actual);
|
||||
memos.expected.push(expected);
|
||||
|
||||
return objEquiv(actual, expected, strict, memos);
|
||||
}
|
||||
}
|
||||
|
||||
function isArguments(object) {
|
||||
return Object.prototype.toString.call(object) == '[object Arguments]';
|
||||
}
|
||||
|
||||
function objEquiv(a, b, strict, actualVisitedObjects) {
|
||||
if (a === null || a === undefined || b === null || b === undefined)
|
||||
return false;
|
||||
// if one is a primitive, the other must be same
|
||||
if (util.isPrimitive(a) || util.isPrimitive(b))
|
||||
return a === b;
|
||||
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
|
||||
return false;
|
||||
var aIsArgs = isArguments(a);
|
||||
var bIsArgs = isArguments(b);
|
||||
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
|
||||
return false;
|
||||
if (aIsArgs) {
|
||||
a = pSlice.call(a);
|
||||
b = pSlice.call(b);
|
||||
return _deepEqual(a, b, strict);
|
||||
}
|
||||
var ka = objectKeys(a);
|
||||
var kb = objectKeys(b);
|
||||
var key, i;
|
||||
// having the same number of owned properties (keys incorporates
|
||||
// hasOwnProperty)
|
||||
if (ka.length !== kb.length)
|
||||
return false;
|
||||
//the same set of keys (although not necessarily the same order),
|
||||
ka.sort();
|
||||
kb.sort();
|
||||
//~~~cheap key test
|
||||
for (i = ka.length - 1; i >= 0; i--) {
|
||||
if (ka[i] !== kb[i])
|
||||
return false;
|
||||
}
|
||||
//equivalent values for every corresponding key, and
|
||||
//~~~possibly expensive deep test
|
||||
for (i = ka.length - 1; i >= 0; i--) {
|
||||
key = ka[i];
|
||||
if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 8. The non-equivalence assertion tests for any deep inequality.
|
||||
// assert.notDeepEqual(actual, expected, message_opt);
|
||||
|
||||
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
|
||||
if (_deepEqual(actual, expected, false)) {
|
||||
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
|
||||
}
|
||||
};
|
||||
|
||||
assert.notDeepStrictEqual = notDeepStrictEqual;
|
||||
function notDeepStrictEqual(actual, expected, message) {
|
||||
if (_deepEqual(actual, expected, true)) {
|
||||
fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 9. The strict equality assertion tests strict equality, as determined by ===.
|
||||
// assert.strictEqual(actual, expected, message_opt);
|
||||
|
||||
assert.strictEqual = function strictEqual(actual, expected, message) {
|
||||
if (actual !== expected) {
|
||||
fail(actual, expected, message, '===', assert.strictEqual);
|
||||
}
|
||||
};
|
||||
|
||||
// 10. The strict non-equality assertion tests for strict inequality, as
|
||||
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
|
||||
|
||||
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
|
||||
if (actual === expected) {
|
||||
fail(actual, expected, message, '!==', assert.notStrictEqual);
|
||||
}
|
||||
};
|
||||
|
||||
function expectedException(actual, expected) {
|
||||
if (!actual || !expected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(expected) == '[object RegExp]') {
|
||||
return expected.test(actual);
|
||||
}
|
||||
|
||||
try {
|
||||
if (actual instanceof expected) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
// Ignore. The instanceof check doesn't work for arrow functions.
|
||||
}
|
||||
|
||||
if (Error.isPrototypeOf(expected)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return expected.call({}, actual) === true;
|
||||
}
|
||||
|
||||
function _tryBlock(block) {
|
||||
var error;
|
||||
try {
|
||||
block();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
function _throws(shouldThrow, block, expected, message) {
|
||||
var actual;
|
||||
|
||||
if (typeof block !== 'function') {
|
||||
throw new TypeError('"block" argument must be a function');
|
||||
}
|
||||
|
||||
if (typeof expected === 'string') {
|
||||
message = expected;
|
||||
expected = null;
|
||||
}
|
||||
|
||||
actual = _tryBlock(block);
|
||||
|
||||
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
|
||||
(message ? ' ' + message : '.');
|
||||
|
||||
if (shouldThrow && !actual) {
|
||||
fail(actual, expected, 'Missing expected exception' + message);
|
||||
}
|
||||
|
||||
var userProvidedMessage = typeof message === 'string';
|
||||
var isUnwantedException = !shouldThrow && util.isError(actual);
|
||||
var isUnexpectedException = !shouldThrow && actual && !expected;
|
||||
|
||||
if ((isUnwantedException &&
|
||||
userProvidedMessage &&
|
||||
expectedException(actual, expected)) ||
|
||||
isUnexpectedException) {
|
||||
fail(actual, expected, 'Got unwanted exception' + message);
|
||||
}
|
||||
|
||||
if ((shouldThrow && actual && expected &&
|
||||
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
|
||||
throw actual;
|
||||
}
|
||||
}
|
||||
|
||||
// 11. Expected to throw an error:
|
||||
// assert.throws(block, Error_opt, message_opt);
|
||||
|
||||
assert.throws = function(block, /*optional*/error, /*optional*/message) {
|
||||
_throws(true, block, error, message);
|
||||
};
|
||||
|
||||
// EXTENSION! This is annoying to write outside this module.
|
||||
assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
|
||||
_throws(false, block, error, message);
|
||||
};
|
||||
|
||||
assert.ifError = function(err) { if (err) throw err; };
|
||||
|
||||
// Expose a strict only variant of assert
|
||||
function strict(value, message) {
|
||||
if (!value) fail(value, true, message, '==', strict);
|
||||
}
|
||||
assert.strict = objectAssign(strict, assert, {
|
||||
equal: assert.strictEqual,
|
||||
deepEqual: assert.deepStrictEqual,
|
||||
notEqual: assert.notStrictEqual,
|
||||
notDeepEqual: assert.notDeepStrictEqual
|
||||
});
|
||||
assert.strict.strict = assert.strict;
|
||||
|
||||
var objectKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) {
|
||||
if (hasOwn.call(obj, key)) keys.push(key);
|
||||
}
|
||||
return keys;
|
||||
};
|
16
node_modules/assert/node_modules/inherits/LICENSE
generated
vendored
Normal file
16
node_modules/assert/node_modules/inherits/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
|
42
node_modules/assert/node_modules/inherits/README.md
generated
vendored
Normal file
42
node_modules/assert/node_modules/inherits/README.md
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
Browser-friendly inheritance fully compatible with standard node.js
|
||||
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
|
||||
|
||||
This package exports standard `inherits` from node.js `util` module in
|
||||
node environment, but also provides alternative browser-friendly
|
||||
implementation through [browser
|
||||
field](https://gist.github.com/shtylman/4339901). Alternative
|
||||
implementation is a literal copy of standard one located in standalone
|
||||
module to avoid requiring of `util`. It also has a shim for old
|
||||
browsers with no `Object.create` support.
|
||||
|
||||
While keeping you sure you are using standard `inherits`
|
||||
implementation in node.js environment, it allows bundlers such as
|
||||
[browserify](https://github.com/substack/node-browserify) to not
|
||||
include full `util` package to your client code if all you need is
|
||||
just `inherits` function. It worth, because browser shim for `util`
|
||||
package is large and `inherits` is often the single function you need
|
||||
from it.
|
||||
|
||||
It's recommended to use this package instead of
|
||||
`require('util').inherits` for any code that has chances to be used
|
||||
not only in node.js but in browser too.
|
||||
|
||||
## usage
|
||||
|
||||
```js
|
||||
var inherits = require('inherits');
|
||||
// then use exactly as the standard one
|
||||
```
|
||||
|
||||
## note on version ~1.0
|
||||
|
||||
Version ~1.0 had completely different motivation and is not compatible
|
||||
neither with 2.0 nor with standard node.js `inherits`.
|
||||
|
||||
If you are using version ~1.0 and planning to switch to ~2.0, be
|
||||
careful:
|
||||
|
||||
* new version uses `super_` instead of `super` for referencing
|
||||
superclass
|
||||
* new version overwrites current prototype while old one preserves any
|
||||
existing fields on it
|
7
node_modules/assert/node_modules/inherits/inherits.js
generated
vendored
Normal file
7
node_modules/assert/node_modules/inherits/inherits.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
try {
|
||||
var util = require('util');
|
||||
if (typeof util.inherits !== 'function') throw '';
|
||||
module.exports = util.inherits;
|
||||
} catch (e) {
|
||||
module.exports = require('./inherits_browser.js');
|
||||
}
|
23
node_modules/assert/node_modules/inherits/inherits_browser.js
generated
vendored
Normal file
23
node_modules/assert/node_modules/inherits/inherits_browser.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
if (typeof Object.create === 'function') {
|
||||
// implementation from standard node.js 'util' module
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
};
|
||||
} else {
|
||||
// old school shim for old browsers
|
||||
module.exports = function inherits(ctor, superCtor) {
|
||||
ctor.super_ = superCtor
|
||||
var TempCtor = function () {}
|
||||
TempCtor.prototype = superCtor.prototype
|
||||
ctor.prototype = new TempCtor()
|
||||
ctor.prototype.constructor = ctor
|
||||
}
|
||||
}
|
29
node_modules/assert/node_modules/inherits/package.json
generated
vendored
Normal file
29
node_modules/assert/node_modules/inherits/package.json
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "inherits",
|
||||
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
|
||||
"version": "2.0.3",
|
||||
"keywords": [
|
||||
"inheritance",
|
||||
"class",
|
||||
"klass",
|
||||
"oop",
|
||||
"object-oriented",
|
||||
"inherits",
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"main": "./inherits.js",
|
||||
"browser": "./inherits_browser.js",
|
||||
"repository": "git://github.com/isaacs/inherits",
|
||||
"license": "ISC",
|
||||
"scripts": {
|
||||
"test": "node test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "^7.1.0"
|
||||
},
|
||||
"files": [
|
||||
"inherits.js",
|
||||
"inherits_browser.js"
|
||||
]
|
||||
}
|
18
node_modules/assert/node_modules/util/LICENSE
generated
vendored
Normal file
18
node_modules/assert/node_modules/util/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
15
node_modules/assert/node_modules/util/README.md
generated
vendored
Normal file
15
node_modules/assert/node_modules/util/README.md
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# util
|
||||
|
||||
[](https://travis-ci.org/defunctzombie/node-util)
|
||||
|
||||
node.js [util](http://nodejs.org/api/util.html) module as a module
|
||||
|
||||
## install via [npm](npmjs.org)
|
||||
|
||||
```shell
|
||||
npm install util
|
||||
```
|
||||
|
||||
## browser support
|
||||
|
||||
This module also works in modern browsers. If you need legacy browser support you will need to polyfill ES5 features.
|
35
node_modules/assert/node_modules/util/package.json
generated
vendored
Normal file
35
node_modules/assert/node_modules/util/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Joyent",
|
||||
"url": "http://www.joyent.com"
|
||||
},
|
||||
"name": "util",
|
||||
"description": "Node.JS util module",
|
||||
"keywords": [
|
||||
"util"
|
||||
],
|
||||
"version": "0.10.4",
|
||||
"homepage": "https://github.com/defunctzombie/node-util",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/defunctzombie/node-util"
|
||||
},
|
||||
"main": "./util.js",
|
||||
"files": [
|
||||
"util.js",
|
||||
"support"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "node test/node/*.js && zuul test/browser/*.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"inherits": "2.0.3"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"zuul": "~1.0.9"
|
||||
},
|
||||
"browser": {
|
||||
"./support/isBuffer.js": "./support/isBufferBrowser.js"
|
||||
}
|
||||
}
|
3
node_modules/assert/node_modules/util/support/isBuffer.js
generated
vendored
Normal file
3
node_modules/assert/node_modules/util/support/isBuffer.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = function isBuffer(arg) {
|
||||
return arg instanceof Buffer;
|
||||
}
|
6
node_modules/assert/node_modules/util/support/isBufferBrowser.js
generated
vendored
Normal file
6
node_modules/assert/node_modules/util/support/isBufferBrowser.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = function isBuffer(arg) {
|
||||
return arg && typeof arg === 'object'
|
||||
&& typeof arg.copy === 'function'
|
||||
&& typeof arg.fill === 'function'
|
||||
&& typeof arg.readUInt8 === 'function';
|
||||
}
|
586
node_modules/assert/node_modules/util/util.js
generated
vendored
Normal file
586
node_modules/assert/node_modules/util/util.js
generated
vendored
Normal file
@@ -0,0 +1,586 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
var formatRegExp = /%[sdj%]/g;
|
||||
exports.format = function(f) {
|
||||
if (!isString(f)) {
|
||||
var objects = [];
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
objects.push(inspect(arguments[i]));
|
||||
}
|
||||
return objects.join(' ');
|
||||
}
|
||||
|
||||
var i = 1;
|
||||
var args = arguments;
|
||||
var len = args.length;
|
||||
var str = String(f).replace(formatRegExp, function(x) {
|
||||
if (x === '%%') return '%';
|
||||
if (i >= len) return x;
|
||||
switch (x) {
|
||||
case '%s': return String(args[i++]);
|
||||
case '%d': return Number(args[i++]);
|
||||
case '%j':
|
||||
try {
|
||||
return JSON.stringify(args[i++]);
|
||||
} catch (_) {
|
||||
return '[Circular]';
|
||||
}
|
||||
default:
|
||||
return x;
|
||||
}
|
||||
});
|
||||
for (var x = args[i]; i < len; x = args[++i]) {
|
||||
if (isNull(x) || !isObject(x)) {
|
||||
str += ' ' + x;
|
||||
} else {
|
||||
str += ' ' + inspect(x);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
|
||||
// Mark that a method should not be used.
|
||||
// Returns a modified function which warns once by default.
|
||||
// If --no-deprecation is set, then it is a no-op.
|
||||
exports.deprecate = function(fn, msg) {
|
||||
// Allow for deprecating things in the process of starting up.
|
||||
if (isUndefined(global.process)) {
|
||||
return function() {
|
||||
return exports.deprecate(fn, msg).apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
if (process.noDeprecation === true) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
var warned = false;
|
||||
function deprecated() {
|
||||
if (!warned) {
|
||||
if (process.throwDeprecation) {
|
||||
throw new Error(msg);
|
||||
} else if (process.traceDeprecation) {
|
||||
console.trace(msg);
|
||||
} else {
|
||||
console.error(msg);
|
||||
}
|
||||
warned = true;
|
||||
}
|
||||
return fn.apply(this, arguments);
|
||||
}
|
||||
|
||||
return deprecated;
|
||||
};
|
||||
|
||||
|
||||
var debugs = {};
|
||||
var debugEnviron;
|
||||
exports.debuglog = function(set) {
|
||||
if (isUndefined(debugEnviron))
|
||||
debugEnviron = process.env.NODE_DEBUG || '';
|
||||
set = set.toUpperCase();
|
||||
if (!debugs[set]) {
|
||||
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
||||
var pid = process.pid;
|
||||
debugs[set] = function() {
|
||||
var msg = exports.format.apply(exports, arguments);
|
||||
console.error('%s %d: %s', set, pid, msg);
|
||||
};
|
||||
} else {
|
||||
debugs[set] = function() {};
|
||||
}
|
||||
}
|
||||
return debugs[set];
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Echos the value of a value. Trys to print the value out
|
||||
* in the best way possible given the different types.
|
||||
*
|
||||
* @param {Object} obj The object to print out.
|
||||
* @param {Object} opts Optional options object that alters the output.
|
||||
*/
|
||||
/* legacy: obj, showHidden, depth, colors*/
|
||||
function inspect(obj, opts) {
|
||||
// default options
|
||||
var ctx = {
|
||||
seen: [],
|
||||
stylize: stylizeNoColor
|
||||
};
|
||||
// legacy...
|
||||
if (arguments.length >= 3) ctx.depth = arguments[2];
|
||||
if (arguments.length >= 4) ctx.colors = arguments[3];
|
||||
if (isBoolean(opts)) {
|
||||
// legacy...
|
||||
ctx.showHidden = opts;
|
||||
} else if (opts) {
|
||||
// got an "options" object
|
||||
exports._extend(ctx, opts);
|
||||
}
|
||||
// set default options
|
||||
if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
||||
if (isUndefined(ctx.depth)) ctx.depth = 2;
|
||||
if (isUndefined(ctx.colors)) ctx.colors = false;
|
||||
if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
||||
if (ctx.colors) ctx.stylize = stylizeWithColor;
|
||||
return formatValue(ctx, obj, ctx.depth);
|
||||
}
|
||||
exports.inspect = inspect;
|
||||
|
||||
|
||||
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
||||
inspect.colors = {
|
||||
'bold' : [1, 22],
|
||||
'italic' : [3, 23],
|
||||
'underline' : [4, 24],
|
||||
'inverse' : [7, 27],
|
||||
'white' : [37, 39],
|
||||
'grey' : [90, 39],
|
||||
'black' : [30, 39],
|
||||
'blue' : [34, 39],
|
||||
'cyan' : [36, 39],
|
||||
'green' : [32, 39],
|
||||
'magenta' : [35, 39],
|
||||
'red' : [31, 39],
|
||||
'yellow' : [33, 39]
|
||||
};
|
||||
|
||||
// Don't use 'blue' not visible on cmd.exe
|
||||
inspect.styles = {
|
||||
'special': 'cyan',
|
||||
'number': 'yellow',
|
||||
'boolean': 'yellow',
|
||||
'undefined': 'grey',
|
||||
'null': 'bold',
|
||||
'string': 'green',
|
||||
'date': 'magenta',
|
||||
// "name": intentionally not styling
|
||||
'regexp': 'red'
|
||||
};
|
||||
|
||||
|
||||
function stylizeWithColor(str, styleType) {
|
||||
var style = inspect.styles[styleType];
|
||||
|
||||
if (style) {
|
||||
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
||||
'\u001b[' + inspect.colors[style][1] + 'm';
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function stylizeNoColor(str, styleType) {
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
function arrayToHash(array) {
|
||||
var hash = {};
|
||||
|
||||
array.forEach(function(val, idx) {
|
||||
hash[val] = true;
|
||||
});
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
function formatValue(ctx, value, recurseTimes) {
|
||||
// Provide a hook for user-specified inspect functions.
|
||||
// Check that value is an object with an inspect function on it
|
||||
if (ctx.customInspect &&
|
||||
value &&
|
||||
isFunction(value.inspect) &&
|
||||
// Filter out the util module, it's inspect function is special
|
||||
value.inspect !== exports.inspect &&
|
||||
// Also filter out any prototype objects using the circular check.
|
||||
!(value.constructor && value.constructor.prototype === value)) {
|
||||
var ret = value.inspect(recurseTimes, ctx);
|
||||
if (!isString(ret)) {
|
||||
ret = formatValue(ctx, ret, recurseTimes);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Primitive types cannot have properties
|
||||
var primitive = formatPrimitive(ctx, value);
|
||||
if (primitive) {
|
||||
return primitive;
|
||||
}
|
||||
|
||||
// Look up the keys of the object.
|
||||
var keys = Object.keys(value);
|
||||
var visibleKeys = arrayToHash(keys);
|
||||
|
||||
if (ctx.showHidden) {
|
||||
keys = Object.getOwnPropertyNames(value);
|
||||
}
|
||||
|
||||
// IE doesn't make error fields non-enumerable
|
||||
// http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx
|
||||
if (isError(value)
|
||||
&& (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
||||
return formatError(value);
|
||||
}
|
||||
|
||||
// Some type of object without properties can be shortcutted.
|
||||
if (keys.length === 0) {
|
||||
if (isFunction(value)) {
|
||||
var name = value.name ? ': ' + value.name : '';
|
||||
return ctx.stylize('[Function' + name + ']', 'special');
|
||||
}
|
||||
if (isRegExp(value)) {
|
||||
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
||||
}
|
||||
if (isDate(value)) {
|
||||
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
||||
}
|
||||
if (isError(value)) {
|
||||
return formatError(value);
|
||||
}
|
||||
}
|
||||
|
||||
var base = '', array = false, braces = ['{', '}'];
|
||||
|
||||
// Make Array say that they are Array
|
||||
if (isArray(value)) {
|
||||
array = true;
|
||||
braces = ['[', ']'];
|
||||
}
|
||||
|
||||
// Make functions say that they are functions
|
||||
if (isFunction(value)) {
|
||||
var n = value.name ? ': ' + value.name : '';
|
||||
base = ' [Function' + n + ']';
|
||||
}
|
||||
|
||||
// Make RegExps say that they are RegExps
|
||||
if (isRegExp(value)) {
|
||||
base = ' ' + RegExp.prototype.toString.call(value);
|
||||
}
|
||||
|
||||
// Make dates with properties first say the date
|
||||
if (isDate(value)) {
|
||||
base = ' ' + Date.prototype.toUTCString.call(value);
|
||||
}
|
||||
|
||||
// Make error with message first say the error
|
||||
if (isError(value)) {
|
||||
base = ' ' + formatError(value);
|
||||
}
|
||||
|
||||
if (keys.length === 0 && (!array || value.length == 0)) {
|
||||
return braces[0] + base + braces[1];
|
||||
}
|
||||
|
||||
if (recurseTimes < 0) {
|
||||
if (isRegExp(value)) {
|
||||
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
||||
} else {
|
||||
return ctx.stylize('[Object]', 'special');
|
||||
}
|
||||
}
|
||||
|
||||
ctx.seen.push(value);
|
||||
|
||||
var output;
|
||||
if (array) {
|
||||
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
||||
} else {
|
||||
output = keys.map(function(key) {
|
||||
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
||||
});
|
||||
}
|
||||
|
||||
ctx.seen.pop();
|
||||
|
||||
return reduceToSingleString(output, base, braces);
|
||||
}
|
||||
|
||||
|
||||
function formatPrimitive(ctx, value) {
|
||||
if (isUndefined(value))
|
||||
return ctx.stylize('undefined', 'undefined');
|
||||
if (isString(value)) {
|
||||
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
||||
.replace(/'/g, "\\'")
|
||||
.replace(/\\"/g, '"') + '\'';
|
||||
return ctx.stylize(simple, 'string');
|
||||
}
|
||||
if (isNumber(value))
|
||||
return ctx.stylize('' + value, 'number');
|
||||
if (isBoolean(value))
|
||||
return ctx.stylize('' + value, 'boolean');
|
||||
// For some reason typeof null is "object", so special case here.
|
||||
if (isNull(value))
|
||||
return ctx.stylize('null', 'null');
|
||||
}
|
||||
|
||||
|
||||
function formatError(value) {
|
||||
return '[' + Error.prototype.toString.call(value) + ']';
|
||||
}
|
||||
|
||||
|
||||
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
||||
var output = [];
|
||||
for (var i = 0, l = value.length; i < l; ++i) {
|
||||
if (hasOwnProperty(value, String(i))) {
|
||||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||||
String(i), true));
|
||||
} else {
|
||||
output.push('');
|
||||
}
|
||||
}
|
||||
keys.forEach(function(key) {
|
||||
if (!key.match(/^\d+$/)) {
|
||||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||||
key, true));
|
||||
}
|
||||
});
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
||||
var name, str, desc;
|
||||
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
||||
if (desc.get) {
|
||||
if (desc.set) {
|
||||
str = ctx.stylize('[Getter/Setter]', 'special');
|
||||
} else {
|
||||
str = ctx.stylize('[Getter]', 'special');
|
||||
}
|
||||
} else {
|
||||
if (desc.set) {
|
||||
str = ctx.stylize('[Setter]', 'special');
|
||||
}
|
||||
}
|
||||
if (!hasOwnProperty(visibleKeys, key)) {
|
||||
name = '[' + key + ']';
|
||||
}
|
||||
if (!str) {
|
||||
if (ctx.seen.indexOf(desc.value) < 0) {
|
||||
if (isNull(recurseTimes)) {
|
||||
str = formatValue(ctx, desc.value, null);
|
||||
} else {
|
||||
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
||||
}
|
||||
if (str.indexOf('\n') > -1) {
|
||||
if (array) {
|
||||
str = str.split('\n').map(function(line) {
|
||||
return ' ' + line;
|
||||
}).join('\n').substr(2);
|
||||
} else {
|
||||
str = '\n' + str.split('\n').map(function(line) {
|
||||
return ' ' + line;
|
||||
}).join('\n');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
str = ctx.stylize('[Circular]', 'special');
|
||||
}
|
||||
}
|
||||
if (isUndefined(name)) {
|
||||
if (array && key.match(/^\d+$/)) {
|
||||
return str;
|
||||
}
|
||||
name = JSON.stringify('' + key);
|
||||
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
||||
name = name.substr(1, name.length - 2);
|
||||
name = ctx.stylize(name, 'name');
|
||||
} else {
|
||||
name = name.replace(/'/g, "\\'")
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/(^"|"$)/g, "'");
|
||||
name = ctx.stylize(name, 'string');
|
||||
}
|
||||
}
|
||||
|
||||
return name + ': ' + str;
|
||||
}
|
||||
|
||||
|
||||
function reduceToSingleString(output, base, braces) {
|
||||
var numLinesEst = 0;
|
||||
var length = output.reduce(function(prev, cur) {
|
||||
numLinesEst++;
|
||||
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
||||
return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
||||
}, 0);
|
||||
|
||||
if (length > 60) {
|
||||
return braces[0] +
|
||||
(base === '' ? '' : base + '\n ') +
|
||||
' ' +
|
||||
output.join(',\n ') +
|
||||
' ' +
|
||||
braces[1];
|
||||
}
|
||||
|
||||
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
||||
}
|
||||
|
||||
|
||||
// NOTE: These type checking functions intentionally don't use `instanceof`
|
||||
// because it is fragile and can be easily faked with `Object.create()`.
|
||||
function isArray(ar) {
|
||||
return Array.isArray(ar);
|
||||
}
|
||||
exports.isArray = isArray;
|
||||
|
||||
function isBoolean(arg) {
|
||||
return typeof arg === 'boolean';
|
||||
}
|
||||
exports.isBoolean = isBoolean;
|
||||
|
||||
function isNull(arg) {
|
||||
return arg === null;
|
||||
}
|
||||
exports.isNull = isNull;
|
||||
|
||||
function isNullOrUndefined(arg) {
|
||||
return arg == null;
|
||||
}
|
||||
exports.isNullOrUndefined = isNullOrUndefined;
|
||||
|
||||
function isNumber(arg) {
|
||||
return typeof arg === 'number';
|
||||
}
|
||||
exports.isNumber = isNumber;
|
||||
|
||||
function isString(arg) {
|
||||
return typeof arg === 'string';
|
||||
}
|
||||
exports.isString = isString;
|
||||
|
||||
function isSymbol(arg) {
|
||||
return typeof arg === 'symbol';
|
||||
}
|
||||
exports.isSymbol = isSymbol;
|
||||
|
||||
function isUndefined(arg) {
|
||||
return arg === void 0;
|
||||
}
|
||||
exports.isUndefined = isUndefined;
|
||||
|
||||
function isRegExp(re) {
|
||||
return isObject(re) && objectToString(re) === '[object RegExp]';
|
||||
}
|
||||
exports.isRegExp = isRegExp;
|
||||
|
||||
function isObject(arg) {
|
||||
return typeof arg === 'object' && arg !== null;
|
||||
}
|
||||
exports.isObject = isObject;
|
||||
|
||||
function isDate(d) {
|
||||
return isObject(d) && objectToString(d) === '[object Date]';
|
||||
}
|
||||
exports.isDate = isDate;
|
||||
|
||||
function isError(e) {
|
||||
return isObject(e) &&
|
||||
(objectToString(e) === '[object Error]' || e instanceof Error);
|
||||
}
|
||||
exports.isError = isError;
|
||||
|
||||
function isFunction(arg) {
|
||||
return typeof arg === 'function';
|
||||
}
|
||||
exports.isFunction = isFunction;
|
||||
|
||||
function isPrimitive(arg) {
|
||||
return arg === null ||
|
||||
typeof arg === 'boolean' ||
|
||||
typeof arg === 'number' ||
|
||||
typeof arg === 'string' ||
|
||||
typeof arg === 'symbol' || // ES6 symbol
|
||||
typeof arg === 'undefined';
|
||||
}
|
||||
exports.isPrimitive = isPrimitive;
|
||||
|
||||
exports.isBuffer = require('./support/isBuffer');
|
||||
|
||||
function objectToString(o) {
|
||||
return Object.prototype.toString.call(o);
|
||||
}
|
||||
|
||||
|
||||
function pad(n) {
|
||||
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
||||
}
|
||||
|
||||
|
||||
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
||||
'Oct', 'Nov', 'Dec'];
|
||||
|
||||
// 26 Feb 16:19:34
|
||||
function timestamp() {
|
||||
var d = new Date();
|
||||
var time = [pad(d.getHours()),
|
||||
pad(d.getMinutes()),
|
||||
pad(d.getSeconds())].join(':');
|
||||
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
||||
}
|
||||
|
||||
|
||||
// log is just a thin wrapper to console.log that prepends a timestamp
|
||||
exports.log = function() {
|
||||
console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Inherit the prototype methods from one constructor into another.
|
||||
*
|
||||
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
||||
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
||||
* during bootstrapping this function needs to be rewritten using some native
|
||||
* functions as prototype setup using normal JavaScript does not work as
|
||||
* expected during bootstrapping (see mirror.js in r114903).
|
||||
*
|
||||
* @param {function} ctor Constructor function which needs to inherit the
|
||||
* prototype.
|
||||
* @param {function} superCtor Constructor function to inherit prototype from.
|
||||
*/
|
||||
exports.inherits = require('inherits');
|
||||
|
||||
exports._extend = function(origin, add) {
|
||||
// Don't do anything if add isn't an object
|
||||
if (!add || !isObject(add)) return origin;
|
||||
|
||||
var keys = Object.keys(add);
|
||||
var i = keys.length;
|
||||
while (i--) {
|
||||
origin[keys[i]] = add[keys[i]];
|
||||
}
|
||||
return origin;
|
||||
};
|
||||
|
||||
function hasOwnProperty(obj, prop) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
}
|
32
node_modules/assert/package.json
generated
vendored
Normal file
32
node_modules/assert/package.json
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "assert",
|
||||
"description": "The node.js assert module, re-packaged for web browsers.",
|
||||
"version": "1.5.1",
|
||||
"dependencies": {
|
||||
"object.assign": "^4.1.4",
|
||||
"util": "^0.10.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "~1.21.4",
|
||||
"zuul": "~3.10.0",
|
||||
"zuul-ngrok": "^4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/browserify/commonjs-assert",
|
||||
"keywords": [
|
||||
"assert",
|
||||
"browser"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./assert.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/browserify/commonjs-assert.git"
|
||||
},
|
||||
"scripts": {
|
||||
"browser-local": "zuul --no-coverage --local 8000 -- test.js",
|
||||
"test": "npm run test-node && npm run test-browser",
|
||||
"test-browser": "zuul -- test.js",
|
||||
"test-native": "TEST_NATIVE=true mocha --ui qunit test.js",
|
||||
"test-node": "mocha --ui qunit test.js"
|
||||
}
|
||||
}
|
360
node_modules/assert/test.js
generated
vendored
Normal file
360
node_modules/assert/test.js
generated
vendored
Normal file
@@ -0,0 +1,360 @@
|
||||
// Copyright Joyent, Inc. and other Node contributors.
|
||||
//
|
||||
// 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.
|
||||
|
||||
var nodeAssert = require('assert');
|
||||
var ourAssert = require('./');
|
||||
var keys = Object.keys;
|
||||
if (process.env.TEST_NATIVE === true) {
|
||||
tests(nodeAssert, 'node assert');
|
||||
} else {
|
||||
tests(ourAssert, 'our assert');
|
||||
}
|
||||
|
||||
function makeBlock(f) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
return function() {
|
||||
return f.apply(this, args);
|
||||
};
|
||||
}
|
||||
|
||||
function tests (assert, what) {
|
||||
test('assert.ok', function () {
|
||||
assert.throws(makeBlock(assert, false), assert.AssertionError, 'ok(false)');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert, true), assert.AssertionError, 'ok(true)');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert, 'test', 'ok(\'test\')'));
|
||||
|
||||
assert.throws(makeBlock(assert.ok, false),
|
||||
assert.AssertionError, 'ok(false)');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.ok, true),
|
||||
assert.AssertionError, 'ok(true)');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.ok, 'test'), 'ok(\'test\')');
|
||||
});
|
||||
|
||||
test('assert.equal', function () {
|
||||
assert.throws(makeBlock(assert.equal, true, false), assert.AssertionError, 'equal');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.equal, null, null), 'equal');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.equal, undefined, undefined), 'equal');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.equal, null, undefined), 'equal');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.equal, true, true), 'equal');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.equal, 2, '2'), 'equal');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.notEqual, true, false), 'notEqual');
|
||||
|
||||
assert.throws(makeBlock(assert.notEqual, true, true),
|
||||
assert.AssertionError, 'notEqual');
|
||||
});
|
||||
|
||||
test('assert.strictEqual', function () {
|
||||
assert.throws(makeBlock(assert.strictEqual, 2, '2'),
|
||||
assert.AssertionError, 'strictEqual');
|
||||
|
||||
assert.throws(makeBlock(assert.strictEqual, null, undefined),
|
||||
assert.AssertionError, 'strictEqual');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.notStrictEqual, 2, '2'), 'notStrictEqual');
|
||||
});
|
||||
|
||||
test('assert.deepStrictEqual', function () {
|
||||
assert.throws(makeBlock(assert.deepStrictEqual, [2], ['2']),
|
||||
assert.AssertionError, 'deepStrictEqual');
|
||||
|
||||
assert.throws(makeBlock(assert.deepStrictEqual, [null], [undefined]),
|
||||
assert.AssertionError, 'deepStrictEqual');
|
||||
|
||||
assert.doesNotThrow(makeBlock(assert.notDeepStrictEqual, [2], ['2']), 'notDeepStrictEqual');
|
||||
});
|
||||
|
||||
test('assert.deepEqual - 7.2', function () {
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, new Date(2000, 3, 14),
|
||||
new Date(2000, 3, 14)), 'deepEqual date');
|
||||
|
||||
assert.throws(makeBlock(assert.deepEqual, new Date(), new Date(2000, 3, 14)),
|
||||
assert.AssertionError,
|
||||
'deepEqual date');
|
||||
});
|
||||
|
||||
test('assert.deepEqual - 7.3', function () {
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, /a/, /a/));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, /a/g, /a/g));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, /a/i, /a/i));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, /a/m, /a/m));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, /a/igm, /a/igm));
|
||||
assert.throws(makeBlock(assert.deepEqual, /ab/, /a/));
|
||||
assert.throws(makeBlock(assert.deepEqual, /a/g, /a/));
|
||||
assert.throws(makeBlock(assert.deepEqual, /a/i, /a/));
|
||||
assert.throws(makeBlock(assert.deepEqual, /a/m, /a/));
|
||||
assert.throws(makeBlock(assert.deepEqual, /a/igm, /a/im));
|
||||
|
||||
var re1 = /a/;
|
||||
re1.lastIndex = 3;
|
||||
assert.throws(makeBlock(assert.deepEqual, re1, /a/));
|
||||
});
|
||||
|
||||
test('assert.deepEqual - 7.4', function () {
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, 4, '4'), 'deepEqual == check');
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, true, 1), 'deepEqual == check');
|
||||
assert.throws(makeBlock(assert.deepEqual, 4, '5'),
|
||||
assert.AssertionError,
|
||||
'deepEqual == check');
|
||||
});
|
||||
|
||||
test('assert.deepEqual - 7.5', function () {
|
||||
// having the same number of owned properties && the same set of keys
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, {a: 4}, {a: 4}));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, {a: 4, b: '2'}, {a: 4, b: '2'}));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, [4], ['4']));
|
||||
assert.throws(makeBlock(assert.deepEqual, {a: 4}, {a: 4, b: true}),
|
||||
assert.AssertionError);
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, ['a'], {0: 'a'}));
|
||||
//(although not necessarily the same order),
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, {a: 4, b: '1'}, {b: '1', a: 4}));
|
||||
var a1 = [1, 2, 3];
|
||||
var a2 = [1, 2, 3];
|
||||
a1.a = 'test';
|
||||
a1.b = true;
|
||||
a2.b = true;
|
||||
a2.a = 'test';
|
||||
assert.throws(makeBlock(assert.deepEqual, keys(a1), keys(a2)),
|
||||
assert.AssertionError);
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, a1, a2));
|
||||
});
|
||||
|
||||
test('assert.deepEqual - ES6 primitives', function () {
|
||||
assert.throws(makeBlock(assert.deepEqual, null, {}), assert.AssertionError);
|
||||
assert.throws(makeBlock(assert.deepEqual, undefined, {}), assert.AssertionError);
|
||||
assert.throws(makeBlock(assert.deepEqual, 'a', ['a']), assert.AssertionError);
|
||||
assert.throws(makeBlock(assert.deepEqual, 'a', {0: 'a'}), assert.AssertionError);
|
||||
assert.throws(makeBlock(assert.deepEqual, 1, {}), assert.AssertionError);
|
||||
assert.throws(makeBlock(assert.deepEqual, true, {}), assert.AssertionError);
|
||||
if (typeof Symbol === 'symbol') {
|
||||
assert.throws(makeBlock(assert.deepEqual, Symbol(), {}), assert.AssertionError);
|
||||
}
|
||||
});
|
||||
|
||||
test('assert.deepEqual - object wrappers', function () {
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, new String('a'), ['a']));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, new String('a'), {0: 'a'}));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, new Number(1), {}));
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, new Boolean(true), {}));
|
||||
});
|
||||
|
||||
test('assert.deepEqual - Buffers', function () {
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, new Buffer([1, 2, 3]), new Buffer([1, 2, 3])));
|
||||
if (typeof global.Uint8Array === 'function') {
|
||||
assert.throws(makeBlock(assert.deepEqual, new Buffer([1, 2, 3]), new Uint8Array([1, 2, 3])));
|
||||
}
|
||||
if (typeof global.Uint16Array === 'function') {
|
||||
assert.doesNotThrow(makeBlock(assert.deepEqual, new Uint16Array([1, 2, 3]), new Uint16Array([1, 2, 3])));
|
||||
}
|
||||
});
|
||||
|
||||
function thrower(errorConstructor) {
|
||||
throw new errorConstructor('test');
|
||||
}
|
||||
|
||||
test('assert - testing the throwing', function () {
|
||||
var aethrow = makeBlock(thrower, assert.AssertionError);
|
||||
aethrow = makeBlock(thrower, assert.AssertionError);
|
||||
|
||||
// the basic calls work
|
||||
assert.throws(makeBlock(thrower, assert.AssertionError),
|
||||
assert.AssertionError, 'message');
|
||||
assert.throws(makeBlock(thrower, assert.AssertionError), assert.AssertionError);
|
||||
assert.throws(makeBlock(thrower, assert.AssertionError));
|
||||
|
||||
// if not passing an error, catch all.
|
||||
assert.throws(makeBlock(thrower, TypeError));
|
||||
|
||||
// when passing a type, only catch errors of the appropriate type
|
||||
var threw = false;
|
||||
try {
|
||||
assert.throws(makeBlock(thrower, TypeError), assert.AssertionError);
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
assert.ok(e instanceof TypeError, 'type');
|
||||
}
|
||||
assert.equal(true, threw,
|
||||
'a.throws with an explicit error is eating extra errors',
|
||||
assert.AssertionError);
|
||||
threw = false;
|
||||
|
||||
// doesNotThrow should pass through all errors
|
||||
try {
|
||||
assert.doesNotThrow(makeBlock(thrower, TypeError), assert.AssertionError);
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
assert.ok(e instanceof TypeError);
|
||||
}
|
||||
assert.equal(true, threw,
|
||||
'a.doesNotThrow with an explicit error is eating extra errors');
|
||||
|
||||
// key difference is that throwing our correct error makes an assertion error
|
||||
try {
|
||||
assert.doesNotThrow(makeBlock(thrower, TypeError), TypeError);
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
assert.ok(e instanceof assert.AssertionError);
|
||||
}
|
||||
assert.equal(true, threw,
|
||||
'a.doesNotThrow is not catching type matching errors');
|
||||
});
|
||||
|
||||
test('assert.ifError', function () {
|
||||
assert.throws(function() {assert.ifError(new Error('test error'))});
|
||||
assert.doesNotThrow(function() {assert.ifError(null)});
|
||||
assert.doesNotThrow(function() {assert.ifError()});
|
||||
});
|
||||
|
||||
test('assert - make sure that validating using constructor really works', function () {
|
||||
var threw = false;
|
||||
try {
|
||||
assert.throws(
|
||||
function() {
|
||||
throw ({});
|
||||
},
|
||||
Array
|
||||
);
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
}
|
||||
assert.ok(threw, 'wrong constructor validation');
|
||||
});
|
||||
|
||||
test('assert - use a RegExp to validate error message', function () {
|
||||
assert.throws(makeBlock(thrower, TypeError), /test/);
|
||||
});
|
||||
|
||||
test('assert - use a fn to validate error object', function () {
|
||||
assert.throws(makeBlock(thrower, TypeError), function(err) {
|
||||
if ((err instanceof TypeError) && /test/.test(err)) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('assert - make sure deepEqual doesn\'t loop forever on circular refs', function () {
|
||||
var b = {};
|
||||
b.b = b;
|
||||
|
||||
var c = {};
|
||||
c.b = c;
|
||||
|
||||
var gotError = false;
|
||||
var equal = true;
|
||||
try {
|
||||
equal = assert.deepEqual(b, c);
|
||||
} catch (e) {
|
||||
gotError = true;
|
||||
}
|
||||
assert.ok(gotError || !equal, gotError ? 'got error': 'are equal');
|
||||
});
|
||||
|
||||
test('assert - ensure reflexivity of deepEqual with `arguments` objects', function() {
|
||||
var args = (function() { return arguments; })();
|
||||
assert.throws(makeBlock(assert.deepEqual, [], args), assert.AssertionError);
|
||||
assert.throws(makeBlock(assert.deepEqual, args, []), assert.AssertionError);
|
||||
});
|
||||
|
||||
test('assert - test assertion message', function () {
|
||||
function testAssertionMessage(actual, expected) {
|
||||
try {
|
||||
assert.equal(actual, '');
|
||||
} catch (e) {
|
||||
assert.equal(e.toString(),
|
||||
['AssertionError:', expected, '==', '\'\''].join(' '));
|
||||
}
|
||||
}
|
||||
testAssertionMessage(undefined, 'undefined');
|
||||
testAssertionMessage(null, 'null');
|
||||
testAssertionMessage(true, 'true');
|
||||
testAssertionMessage(false, 'false');
|
||||
testAssertionMessage(0, '0');
|
||||
testAssertionMessage(100, '100');
|
||||
testAssertionMessage(NaN, 'NaN');
|
||||
testAssertionMessage(Infinity, 'Infinity');
|
||||
testAssertionMessage(-Infinity, '-Infinity');
|
||||
testAssertionMessage('', '""');
|
||||
testAssertionMessage('foo', '\'foo\'');
|
||||
testAssertionMessage([], '[]');
|
||||
testAssertionMessage([1, 2, 3], '[ 1, 2, 3 ]');
|
||||
testAssertionMessage(new Buffer([1, 2, 3]), '<Buffer 01 02 03>');
|
||||
if (typeof global.Uint8Array === 'function' && Object.getOwnPropertyNames( new Uint8Array([])).length === 0) {
|
||||
// todo fix util.inspect
|
||||
testAssertionMessage(new Uint8Array([1, 2, 3]), '{ \'0\': 1, \'1\': 2, \'2\': 3 }');
|
||||
}
|
||||
testAssertionMessage(/a/, '/a/');
|
||||
testAssertionMessage(function f() {}, '[Function: f]');
|
||||
testAssertionMessage({}, '{}');
|
||||
testAssertionMessage({a: undefined, b: null}, '{ a: undefined, b: null }');
|
||||
testAssertionMessage({a: NaN, b: Infinity, c: -Infinity},
|
||||
'{ a: NaN, b: Infinity, c: -Infinity }');
|
||||
});
|
||||
|
||||
test('assert - regressions from node.js testcase', function () {
|
||||
var threw = false;
|
||||
|
||||
try {
|
||||
assert.throws(function () {
|
||||
assert.ifError(null);
|
||||
});
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
assert.equal(e.message, 'Missing expected exception..');
|
||||
}
|
||||
assert.ok(threw);
|
||||
|
||||
try {
|
||||
assert.equal(1, 2);
|
||||
} catch (e) {
|
||||
assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2');
|
||||
}
|
||||
|
||||
try {
|
||||
assert.equal(1, 2, 'oh no');
|
||||
} catch (e) {
|
||||
assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no');
|
||||
}
|
||||
});
|
||||
|
||||
test('assert - strict mode', function () {
|
||||
var assertStrict = assert.strict;
|
||||
|
||||
assertStrict.throws(makeBlock(assertStrict.equal, 1, true), assertStrict.AssertionError);
|
||||
assertStrict.notEqual(0, false);
|
||||
assertStrict.throws(makeBlock(assertStrict.deepEqual, 1, true), assertStrict.AssertionError);
|
||||
assertStrict.notDeepEqual(0, false);
|
||||
assertStrict.equal(assertStrict.strict, assertStrict.strict.strict);
|
||||
assertStrict.equal(assertStrict.equal, assertStrict.strictEqual);
|
||||
assertStrict.equal(assertStrict.deepEqual, assertStrict.deepStrictEqual);
|
||||
assertStrict.equal(assertStrict.notEqual, assertStrict.notStrictEqual);
|
||||
assertStrict.equal(assertStrict.notDeepEqual, assertStrict.notDeepStrictEqual);
|
||||
assertStrict.equal(Object.keys(assertStrict).length, Object.keys(assert).length);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user