summaryrefslogtreecommitdiffstats
path: root/node_modules/object-inspect/test
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/object-inspect/test')
-rw-r--r--node_modules/object-inspect/test/bigint.js31
-rw-r--r--node_modules/object-inspect/test/browser/dom.js15
-rw-r--r--node_modules/object-inspect/test/circular.js9
-rw-r--r--node_modules/object-inspect/test/deep.js9
-rw-r--r--node_modules/object-inspect/test/element.js53
-rw-r--r--node_modules/object-inspect/test/err.js31
-rw-r--r--node_modules/object-inspect/test/fn.js28
-rw-r--r--node_modules/object-inspect/test/has.js34
-rw-r--r--node_modules/object-inspect/test/holes.js15
-rw-r--r--node_modules/object-inspect/test/indent-option.js271
-rw-r--r--node_modules/object-inspect/test/inspect.js35
-rw-r--r--node_modules/object-inspect/test/lowbyte.js12
-rw-r--r--node_modules/object-inspect/test/number.js12
-rw-r--r--node_modules/object-inspect/test/quoteStyle.js17
-rw-r--r--node_modules/object-inspect/test/undef.js12
-rw-r--r--node_modules/object-inspect/test/values.js171
16 files changed, 0 insertions, 755 deletions
diff --git a/node_modules/object-inspect/test/bigint.js b/node_modules/object-inspect/test/bigint.js
deleted file mode 100644
index 3259143..0000000
--- a/node_modules/object-inspect/test/bigint.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-test('bigint', { skip: typeof BigInt === 'undefined' }, function (t) {
- t.test('primitives', function (st) {
- st.plan(3);
-
- st.equal(inspect(BigInt(-256)), '-256n');
- st.equal(inspect(BigInt(0)), '0n');
- st.equal(inspect(BigInt(256)), '256n');
- });
-
- t.test('objects', function (st) {
- st.plan(3);
-
- st.equal(inspect(Object(BigInt(-256))), 'Object(-256n)');
- st.equal(inspect(Object(BigInt(0))), 'Object(0n)');
- st.equal(inspect(Object(BigInt(256))), 'Object(256n)');
- });
-
- t.test('syntactic primitives', function (st) {
- st.plan(3);
-
- /* eslint-disable no-new-func */
- st.equal(inspect(Function('return -256n')()), '-256n');
- st.equal(inspect(Function('return 0n')()), '0n');
- st.equal(inspect(Function('return 256n')()), '256n');
- });
-
- t.end();
-});
diff --git a/node_modules/object-inspect/test/browser/dom.js b/node_modules/object-inspect/test/browser/dom.js
deleted file mode 100644
index 210c0b2..0000000
--- a/node_modules/object-inspect/test/browser/dom.js
+++ /dev/null
@@ -1,15 +0,0 @@
-var inspect = require('../../');
-var test = require('tape');
-
-test('dom element', function (t) {
- t.plan(1);
-
- var d = document.createElement('div');
- d.setAttribute('id', 'beep');
- d.innerHTML = '<b>wooo</b><i>iiiii</i>';
-
- t.equal(
- inspect([d, { a: 3, b: 4, c: [5, 6, [7, [8, [9]]]] }]),
- '[ <div id="beep">...</div>, { a: 3, b: 4, c: [ 5, 6, [ 7, [ 8, [Object] ] ] ] } ]'
- );
-});
diff --git a/node_modules/object-inspect/test/circular.js b/node_modules/object-inspect/test/circular.js
deleted file mode 100644
index e864cfe..0000000
--- a/node_modules/object-inspect/test/circular.js
+++ /dev/null
@@ -1,9 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-test('circular', function (t) {
- t.plan(1);
- var obj = { a: 1, b: [3, 4] };
- obj.c = obj;
- t.equal(inspect(obj), '{ a: 1, b: [ 3, 4 ], c: [Circular] }');
-});
diff --git a/node_modules/object-inspect/test/deep.js b/node_modules/object-inspect/test/deep.js
deleted file mode 100644
index ff1c7ea..0000000
--- a/node_modules/object-inspect/test/deep.js
+++ /dev/null
@@ -1,9 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-test('deep', function (t) {
- t.plan(2);
- var obj = [[[[[[500]]]]]];
- t.equal(inspect(obj), '[ [ [ [ [ [Array] ] ] ] ] ]');
- t.equal(inspect(obj, { depth: 2 }), '[ [ [Array] ] ]');
-});
diff --git a/node_modules/object-inspect/test/element.js b/node_modules/object-inspect/test/element.js
deleted file mode 100644
index 47fa9e2..0000000
--- a/node_modules/object-inspect/test/element.js
+++ /dev/null
@@ -1,53 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-test('element', function (t) {
- t.plan(3);
- var elem = {
- nodeName: 'div',
- attributes: [{ name: 'class', value: 'row' }],
- getAttribute: function (key) { return key; },
- childNodes: []
- };
- var obj = [1, elem, 3];
- t.deepEqual(inspect(obj), '[ 1, <div class="row"></div>, 3 ]');
- t.deepEqual(inspect(obj, { quoteStyle: 'single' }), "[ 1, <div class='row'></div>, 3 ]");
- t.deepEqual(inspect(obj, { quoteStyle: 'double' }), '[ 1, <div class="row"></div>, 3 ]');
-});
-
-test('element no attr', function (t) {
- t.plan(1);
- var elem = {
- nodeName: 'div',
- getAttribute: function (key) { return key; },
- childNodes: []
- };
- var obj = [1, elem, 3];
- t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
-});
-
-test('element with contents', function (t) {
- t.plan(1);
- var elem = {
- nodeName: 'div',
- getAttribute: function (key) { return key; },
- childNodes: [{ nodeName: 'b' }]
- };
- var obj = [1, elem, 3];
- t.deepEqual(inspect(obj), '[ 1, <div>...</div>, 3 ]');
-});
-
-test('element instance', function (t) {
- t.plan(1);
- var h = global.HTMLElement;
- global.HTMLElement = function (name, attr) {
- this.nodeName = name;
- this.attributes = attr;
- };
- global.HTMLElement.prototype.getAttribute = function () {};
-
- var elem = new global.HTMLElement('div', []);
- var obj = [1, elem, 3];
- t.deepEqual(inspect(obj), '[ 1, <div></div>, 3 ]');
- global.HTMLElement = h;
-});
diff --git a/node_modules/object-inspect/test/err.js b/node_modules/object-inspect/test/err.js
deleted file mode 100644
index db96338..0000000
--- a/node_modules/object-inspect/test/err.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-test('type error', function (t) {
- t.plan(1);
- var aerr = new TypeError();
- aerr.foo = 555;
- aerr.bar = [1, 2, 3];
-
- var berr = new TypeError('tuv');
- berr.baz = 555;
-
- var cerr = new SyntaxError();
- cerr.message = 'whoa';
- cerr['a-b'] = 5;
-
- var obj = [
- new TypeError(),
- new TypeError('xxx'),
- aerr,
- berr,
- cerr
- ];
- t.equal(inspect(obj), '[ ' + [
- '[TypeError]',
- '[TypeError: xxx]',
- '{ [TypeError] foo: 555, bar: [ 1, 2, 3 ] }',
- '{ [TypeError: tuv] baz: 555 }',
- '{ [SyntaxError: whoa] message: \'whoa\', \'a-b\': 5 }'
- ].join(', ') + ' ]');
-});
diff --git a/node_modules/object-inspect/test/fn.js b/node_modules/object-inspect/test/fn.js
deleted file mode 100644
index c69ef8e..0000000
--- a/node_modules/object-inspect/test/fn.js
+++ /dev/null
@@ -1,28 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-test('function', function (t) {
- t.plan(1);
- var obj = [1, 2, function f(n) { return n; }, 4];
- t.equal(inspect(obj), '[ 1, 2, [Function: f], 4 ]');
-});
-
-test('function name', function (t) {
- t.plan(1);
- var f = (function () {
- return function () {};
- }());
- f.toString = function () { return 'function xxx () {}'; };
- var obj = [1, 2, f, 4];
- t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)], 4 ]');
-});
-
-test('anon function', function (t) {
- var f = (function () {
- return function () {};
- }());
- var obj = [1, 2, f, 4];
- t.equal(inspect(obj), '[ 1, 2, [Function (anonymous)], 4 ]');
-
- t.end();
-});
diff --git a/node_modules/object-inspect/test/has.js b/node_modules/object-inspect/test/has.js
deleted file mode 100644
index 026d6d5..0000000
--- a/node_modules/object-inspect/test/has.js
+++ /dev/null
@@ -1,34 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-function withoutProperty(object, property, fn) {
- var original;
- if (Object.getOwnPropertyDescriptor) {
- original = Object.getOwnPropertyDescriptor(object, property);
- } else {
- original = object[property];
- }
- delete object[property];
- try {
- fn();
- } finally {
- if (Object.getOwnPropertyDescriptor) {
- Object.defineProperty(object, property, original);
- } else {
- object[property] = original;
- }
- }
-}
-
-test('when Object#hasOwnProperty is deleted', function (t) {
- t.plan(1);
- var arr = [1, , 3]; // eslint-disable-line no-sparse-arrays
-
- // eslint-disable-next-line no-extend-native
- Array.prototype[1] = 2; // this is needed to account for "in" vs "hasOwnProperty"
-
- withoutProperty(Object.prototype, 'hasOwnProperty', function () {
- t.equal(inspect(arr), '[ 1, , 3 ]');
- });
- delete Array.prototype[1];
-});
diff --git a/node_modules/object-inspect/test/holes.js b/node_modules/object-inspect/test/holes.js
deleted file mode 100644
index 87fc8c8..0000000
--- a/node_modules/object-inspect/test/holes.js
+++ /dev/null
@@ -1,15 +0,0 @@
-var test = require('tape');
-var inspect = require('../');
-
-var xs = ['a', 'b'];
-xs[5] = 'f';
-xs[7] = 'j';
-xs[8] = 'k';
-
-test('holes', function (t) {
- t.plan(1);
- t.equal(
- inspect(xs),
- "[ 'a', 'b', , , , 'f', , 'j', 'k' ]"
- );
-});
diff --git a/node_modules/object-inspect/test/indent-option.js b/node_modules/object-inspect/test/indent-option.js
deleted file mode 100644
index 89d8fce..0000000
--- a/node_modules/object-inspect/test/indent-option.js
+++ /dev/null
@@ -1,271 +0,0 @@
-var test = require('tape');
-var forEach = require('for-each');
-
-var inspect = require('../');
-
-test('bad indent options', function (t) {
- forEach([
- undefined,
- true,
- false,
- -1,
- 1.2,
- Infinity,
- -Infinity,
- NaN
- ], function (indent) {
- t['throws'](
- function () { inspect('', { indent: indent }); },
- TypeError,
- inspect(indent) + ' is invalid'
- );
- });
-
- t.end();
-});
-
-test('simple object with indent', function (t) {
- t.plan(2);
-
- var obj = { a: 1, b: 2 };
-
- var expectedSpaces = [
- '{',
- ' a: 1,',
- ' b: 2',
- '}'
- ].join('\n');
- var expectedTabs = [
- '{',
- ' a: 1,',
- ' b: 2',
- '}'
- ].join('\n');
-
- t.equal(inspect(obj, { indent: 2 }), expectedSpaces, 'two');
- t.equal(inspect(obj, { indent: '\t' }), expectedTabs, 'tabs');
-});
-
-test('two deep object with indent', function (t) {
- t.plan(2);
-
- var obj = { a: 1, b: { c: 3, d: 4 } };
-
- var expectedSpaces = [
- '{',
- ' a: 1,',
- ' b: {',
- ' c: 3,',
- ' d: 4',
- ' }',
- '}'
- ].join('\n');
- var expectedTabs = [
- '{',
- ' a: 1,',
- ' b: {',
- ' c: 3,',
- ' d: 4',
- ' }',
- '}'
- ].join('\n');
-
- t.equal(inspect(obj, { indent: 2 }), expectedSpaces, 'two');
- t.equal(inspect(obj, { indent: '\t' }), expectedTabs, 'tabs');
-});
-
-test('simple array with all single line elements', function (t) {
- t.plan(2);
-
- var obj = [1, 2, 3, 'asdf\nsdf'];
-
- var expected = '[ 1, 2, 3, \'asdf\\nsdf\' ]';
-
- t.equal(inspect(obj, { indent: 2 }), expected, 'two');
- t.equal(inspect(obj, { indent: '\t' }), expected, 'tabs');
-});
-
-test('array with complex elements', function (t) {
- t.plan(2);
-
- var obj = [1, { a: 1, b: { c: 1 } }, 'asdf\nsdf'];
-
- var expectedSpaces = [
- '[',
- ' 1,',
- ' {',
- ' a: 1,',
- ' b: {',
- ' c: 1',
- ' }',
- ' },',
- ' \'asdf\\nsdf\'',
- ']'
- ].join('\n');
- var expectedTabs = [
- '[',
- ' 1,',
- ' {',
- ' a: 1,',
- ' b: {',
- ' c: 1',
- ' }',
- ' },',
- ' \'asdf\\nsdf\'',
- ']'
- ].join('\n');
-
- t.equal(inspect(obj, { indent: 2 }), expectedSpaces, 'two');
- t.equal(inspect(obj, { indent: '\t' }), expectedTabs, 'tabs');
-});
-
-test('values', function (t) {
- t.plan(2);
- var obj = [{}, [], { 'a-b': 5 }];
-
- var expectedSpaces = [
- '[',
- ' {},',
- ' [],',
- ' {',
- ' \'a-b\': 5',
- ' }',
- ']'
- ].join('\n');
- var expectedTabs = [
- '[',
- ' {},',
- ' [],',
- ' {',
- ' \'a-b\': 5',
- ' }',
- ']'
- ].join('\n');
-
- t.equal(inspect(obj, { indent: 2 }), expectedSpaces, 'two');
- t.equal(inspect(obj, { indent: '\t' }), expectedTabs, 'tabs');
-});
-
-test('Map', { skip: typeof Map !== 'function' }, function (t) {
- var map = new Map();
- map.set({ a: 1 }, ['b']);
- map.set(3, NaN);
-
- var expectedStringSpaces = [
- 'Map (2) {',
- ' { a: 1 } => [ \'b\' ],',
- ' 3 => NaN',
- '}'
- ].join('\n');
- var expectedStringTabs = [
- 'Map (2) {',
- ' { a: 1 } => [ \'b\' ],',
- ' 3 => NaN',
- '}'
- ].join('\n');
- var expectedStringTabsDoubleQuotes = [
- 'Map (2) {',
- ' { a: 1 } => [ "b" ],',
- ' 3 => NaN',
- '}'
- ].join('\n');
-
- t.equal(
- inspect(map, { indent: 2 }),
- expectedStringSpaces,
- 'Map keys are not indented (two)'
- );
- t.equal(
- inspect(map, { indent: '\t' }),
- expectedStringTabs,
- 'Map keys are not indented (tabs)'
- );
- t.equal(
- inspect(map, { indent: '\t', quoteStyle: 'double' }),
- expectedStringTabsDoubleQuotes,
- 'Map keys are not indented (tabs + double quotes)'
- );
-
- t.equal(inspect(new Map(), { indent: 2 }), 'Map (0) {}', 'empty Map should show as empty (two)');
- t.equal(inspect(new Map(), { indent: '\t' }), 'Map (0) {}', 'empty Map should show as empty (tabs)');
-
- var nestedMap = new Map();
- nestedMap.set(nestedMap, map);
- var expectedNestedSpaces = [
- 'Map (1) {',
- ' [Circular] => Map (2) {',
- ' { a: 1 } => [ \'b\' ],',
- ' 3 => NaN',
- ' }',
- '}'
- ].join('\n');
- var expectedNestedTabs = [
- 'Map (1) {',
- ' [Circular] => Map (2) {',
- ' { a: 1 } => [ \'b\' ],',
- ' 3 => NaN',
- ' }',
- '}'
- ].join('\n');
- t.equal(inspect(nestedMap, { indent: 2 }), expectedNestedSpaces, 'Map containing a Map should work (two)');
- t.equal(inspect(nestedMap, { indent: '\t' }), expectedNestedTabs, 'Map containing a Map should work (tabs)');
-
- t.end();
-});
-
-test('Set', { skip: typeof Set !== 'function' }, function (t) {
- var set = new Set();
- set.add({ a: 1 });
- set.add(['b']);
- var expectedStringSpaces = [
- 'Set (2) {',
- ' {',
- ' a: 1',
- ' },',
- ' [ \'b\' ]',
- '}'
- ].join('\n');
- var expectedStringTabs = [
- 'Set (2) {',
- ' {',
- ' a: 1',
- ' },',
- ' [ \'b\' ]',
- '}'
- ].join('\n');
- t.equal(inspect(set, { indent: 2 }), expectedStringSpaces, 'new Set([{ a: 1 }, ["b"]]) should show size and contents (two)');
- t.equal(inspect(set, { indent: '\t' }), expectedStringTabs, 'new Set([{ a: 1 }, ["b"]]) should show size and contents (tabs)');
-
- t.equal(inspect(new Set(), { indent: 2 }), 'Set (0) {}', 'empty Set should show as empty (two)');
- t.equal(inspect(new Set(), { indent: '\t' }), 'Set (0) {}', 'empty Set should show as empty (tabs)');
-
- var nestedSet = new Set();
- nestedSet.add(set);
- nestedSet.add(nestedSet);
- var expectedNestedSpaces = [
- 'Set (2) {',
- ' Set (2) {',
- ' {',
- ' a: 1',
- ' },',
- ' [ \'b\' ]',
- ' },',
- ' [Circular]',
- '}'
- ].join('\n');
- var expectedNestedTabs = [
- 'Set (2) {',
- ' Set (2) {',
- ' {',
- ' a: 1',
- ' },',
- ' [ \'b\' ]',
- ' },',
- ' [Circular]',
- '}'
- ].join('\n');
- t.equal(inspect(nestedSet, { indent: 2 }), expectedNestedSpaces, 'Set containing a Set should work (two)');
- t.equal(inspect(nestedSet, { indent: '\t' }), expectedNestedTabs, 'Set containing a Set should work (tabs)');
-
- t.end();
-});
diff --git a/node_modules/object-inspect/test/inspect.js b/node_modules/object-inspect/test/inspect.js
deleted file mode 100644
index 2277e4c..0000000
--- a/node_modules/object-inspect/test/inspect.js
+++ /dev/null
@@ -1,35 +0,0 @@
-var test = require('tape');
-var hasSymbols = require('has-symbols')();
-var utilInspect = require('../util.inspect');
-var repeat = require('string.prototype.repeat');
-
-var inspect = require('..');
-
-test('inspect', function (t) {
- t.plan(3);
- var obj = [{ inspect: function xyzInspect() { return '!XYZ¡'; } }, []];
- t.equal(inspect(obj), '[ !XYZ¡, [] ]');
- t.equal(inspect(obj, { customInspect: true }), '[ !XYZ¡, [] ]');
- t.equal(inspect(obj, { customInspect: false }), '[ { inspect: [Function: xyzInspect] }, [] ]');
-});
-
-test('inspect custom symbol', { skip: !hasSymbols || !utilInspect || !utilInspect.custom }, function (t) {
- t.plan(3);
-
- var obj = { inspect: function stringInspect() { return 'string'; } };
- obj[utilInspect.custom] = function custom() { return 'symbol'; };
-
- t.equal(inspect([obj, []]), '[ ' + (utilInspect.custom ? 'symbol' : 'string') + ', [] ]');
- t.equal(inspect([obj, []], { customInspect: true }), '[ ' + (utilInspect.custom ? 'symbol' : 'string') + ', [] ]');
- t.equal(inspect([obj, []], { customInspect: false }), '[ { inspect: [Function: stringInspect] }, [] ]');
-});
-
-test('maxStringLength', function (t) {
- t.equal(
- inspect([repeat('a', 1e8)], { maxStringLength: 10 }),
- '[ \'aaaaaaaaaa\'... 99999990 more characters ]',
- 'maxStringLength option limits output'
- );
-
- t.end();
-});
diff --git a/node_modules/object-inspect/test/lowbyte.js b/node_modules/object-inspect/test/lowbyte.js
deleted file mode 100644
index d234242..0000000
--- a/node_modules/object-inspect/test/lowbyte.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var test = require('tape');
-var inspect = require('../');
-
-var obj = { x: 'a\r\nb', y: '\x05! \x1f \x12' };
-
-test('interpolate low bytes', function (t) {
- t.plan(1);
- t.equal(
- inspect(obj),
- "{ x: 'a\\r\\nb', y: '\\x05! \\x1f \\x12' }"
- );
-});
diff --git a/node_modules/object-inspect/test/number.js b/node_modules/object-inspect/test/number.js
deleted file mode 100644
index 448304e..0000000
--- a/node_modules/object-inspect/test/number.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-test('negative zero', function (t) {
- t.equal(inspect(0), '0', 'inspect(0) === "0"');
- t.equal(inspect(Object(0)), 'Object(0)', 'inspect(Object(0)) === "Object(0)"');
-
- t.equal(inspect(-0), '-0', 'inspect(-0) === "-0"');
- t.equal(inspect(Object(-0)), 'Object(-0)', 'inspect(Object(-0)) === "Object(-0)"');
-
- t.end();
-});
diff --git a/node_modules/object-inspect/test/quoteStyle.js b/node_modules/object-inspect/test/quoteStyle.js
deleted file mode 100644
index ae4d734..0000000
--- a/node_modules/object-inspect/test/quoteStyle.js
+++ /dev/null
@@ -1,17 +0,0 @@
-'use strict';
-
-var inspect = require('../');
-var test = require('tape');
-
-test('quoteStyle option', function (t) {
- t['throws'](function () { inspect(null, { quoteStyle: false }); }, 'false is not a valid value');
- t['throws'](function () { inspect(null, { quoteStyle: true }); }, 'true is not a valid value');
- t['throws'](function () { inspect(null, { quoteStyle: '' }); }, '"" is not a valid value');
- t['throws'](function () { inspect(null, { quoteStyle: {} }); }, '{} is not a valid value');
- t['throws'](function () { inspect(null, { quoteStyle: [] }); }, '[] is not a valid value');
- t['throws'](function () { inspect(null, { quoteStyle: 42 }); }, '42 is not a valid value');
- t['throws'](function () { inspect(null, { quoteStyle: NaN }); }, 'NaN is not a valid value');
- t['throws'](function () { inspect(null, { quoteStyle: function () {} }); }, 'a function is not a valid value');
-
- t.end();
-});
diff --git a/node_modules/object-inspect/test/undef.js b/node_modules/object-inspect/test/undef.js
deleted file mode 100644
index e3f4961..0000000
--- a/node_modules/object-inspect/test/undef.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var test = require('tape');
-var inspect = require('../');
-
-var obj = { a: 1, b: [3, 4, undefined, null], c: undefined, d: null };
-
-test('undef and null', function (t) {
- t.plan(1);
- t.equal(
- inspect(obj),
- '{ a: 1, b: [ 3, 4, undefined, null ], c: undefined, d: null }'
- );
-});
diff --git a/node_modules/object-inspect/test/values.js b/node_modules/object-inspect/test/values.js
deleted file mode 100644
index 0d40a5f..0000000
--- a/node_modules/object-inspect/test/values.js
+++ /dev/null
@@ -1,171 +0,0 @@
-var inspect = require('../');
-var test = require('tape');
-
-test('values', function (t) {
- t.plan(1);
- var obj = [{}, [], { 'a-b': 5 }];
- t.equal(inspect(obj), '[ {}, [], { \'a-b\': 5 } ]');
-});
-
-test('arrays with properties', function (t) {
- t.plan(1);
- var arr = [3];
- arr.foo = 'bar';
- var obj = [1, 2, arr];
- obj.baz = 'quux';
- obj.index = -1;
- t.equal(inspect(obj), '[ 1, 2, [ 3, foo: \'bar\' ], baz: \'quux\', index: -1 ]');
-});
-
-test('has', function (t) {
- t.plan(1);
- var has = Object.prototype.hasOwnProperty;
- delete Object.prototype.hasOwnProperty;
- t.equal(inspect({ a: 1, b: 2 }), '{ a: 1, b: 2 }');
- Object.prototype.hasOwnProperty = has; // eslint-disable-line no-extend-native
-});
-
-test('indexOf seen', function (t) {
- t.plan(1);
- var xs = [1, 2, 3, {}];
- xs.push(xs);
-
- var seen = [];
- seen.indexOf = undefined;
-
- t.equal(
- inspect(xs, {}, 0, seen),
- '[ 1, 2, 3, {}, [Circular] ]'
- );
-});
-
-test('seen seen', function (t) {
- t.plan(1);
- var xs = [1, 2, 3];
-
- var seen = [xs];
- seen.indexOf = undefined;
-
- t.equal(
- inspect(xs, {}, 0, seen),
- '[Circular]'
- );
-});
-
-test('seen seen seen', function (t) {
- t.plan(1);
- var xs = [1, 2, 3];
-
- var seen = [5, xs];
- seen.indexOf = undefined;
-
- t.equal(
- inspect(xs, {}, 0, seen),
- '[Circular]'
- );
-});
-
-test('symbols', { skip: typeof Symbol !== 'function' }, function (t) {
- var sym = Symbol('foo');
- t.equal(inspect(sym), 'Symbol(foo)', 'Symbol("foo") should be "Symbol(foo)"');
- t.equal(inspect(Object(sym)), 'Object(Symbol(foo))', 'Object(Symbol("foo")) should be "Object(Symbol(foo))"');
- t.end();
-});
-
-test('Map', { skip: typeof Map !== 'function' }, function (t) {
- var map = new Map();
- map.set({ a: 1 }, ['b']);
- map.set(3, NaN);
- var expectedString = 'Map (2) {' + inspect({ a: 1 }) + ' => ' + inspect(['b']) + ', 3 => NaN}';
- t.equal(inspect(map), expectedString, 'new Map([[{ a: 1 }, ["b"]], [3, NaN]]) should show size and contents');
- t.equal(inspect(new Map()), 'Map (0) {}', 'empty Map should show as empty');
-
- var nestedMap = new Map();
- nestedMap.set(nestedMap, map);
- t.equal(inspect(nestedMap), 'Map (1) {[Circular] => ' + expectedString + '}', 'Map containing a Map should work');
-
- t.end();
-});
-
-test('WeakMap', { skip: typeof WeakMap !== 'function' }, function (t) {
- var map = new WeakMap();
- map.set({ a: 1 }, ['b']);
- var expectedString = 'WeakMap { ? }';
- t.equal(inspect(map), expectedString, 'new WeakMap([[{ a: 1 }, ["b"]]]) should not show size or contents');
- t.equal(inspect(new WeakMap()), 'WeakMap { ? }', 'empty WeakMap should not show as empty');
-
- t.end();
-});
-
-test('Set', { skip: typeof Set !== 'function' }, function (t) {
- var set = new Set();
- set.add({ a: 1 });
- set.add(['b']);
- var expectedString = 'Set (2) {' + inspect({ a: 1 }) + ', ' + inspect(['b']) + '}';
- t.equal(inspect(set), expectedString, 'new Set([{ a: 1 }, ["b"]]) should show size and contents');
- t.equal(inspect(new Set()), 'Set (0) {}', 'empty Set should show as empty');
-
- var nestedSet = new Set();
- nestedSet.add(set);
- nestedSet.add(nestedSet);
- t.equal(inspect(nestedSet), 'Set (2) {' + expectedString + ', [Circular]}', 'Set containing a Set should work');
-
- t.end();
-});
-
-test('WeakSet', { skip: typeof WeakSet !== 'function' }, function (t) {
- var map = new WeakSet();
- map.add({ a: 1 });
- var expectedString = 'WeakSet { ? }';
- t.equal(inspect(map), expectedString, 'new WeakSet([{ a: 1 }]) should not show size or contents');
- t.equal(inspect(new WeakSet()), 'WeakSet { ? }', 'empty WeakSet should not show as empty');
-
- t.end();
-});
-
-test('Strings', function (t) {
- var str = 'abc';
-
- t.equal(inspect(str), "'" + str + "'", 'primitive string shows as such');
- t.equal(inspect(str, { quoteStyle: 'single' }), "'" + str + "'", 'primitive string shows as such, single quoted');
- t.equal(inspect(str, { quoteStyle: 'double' }), '"' + str + '"', 'primitive string shows as such, double quoted');
- t.equal(inspect(Object(str)), 'Object(' + inspect(str) + ')', 'String object shows as such');
- t.equal(inspect(Object(str), { quoteStyle: 'single' }), 'Object(' + inspect(str, { quoteStyle: 'single' }) + ')', 'String object shows as such, single quoted');
- t.equal(inspect(Object(str), { quoteStyle: 'double' }), 'Object(' + inspect(str, { quoteStyle: 'double' }) + ')', 'String object shows as such, double quoted');
-
- t.end();
-});
-
-test('Numbers', function (t) {
- var num = 42;
-
- t.equal(inspect(num), String(num), 'primitive number shows as such');
- t.equal(inspect(Object(num)), 'Object(' + inspect(num) + ')', 'Number object shows as such');
-
- t.end();
-});
-
-test('Booleans', function (t) {
- t.equal(inspect(true), String(true), 'primitive true shows as such');
- t.equal(inspect(Object(true)), 'Object(' + inspect(true) + ')', 'Boolean object true shows as such');
-
- t.equal(inspect(false), String(false), 'primitive false shows as such');
- t.equal(inspect(Object(false)), 'Object(' + inspect(false) + ')', 'Boolean false object shows as such');
-
- t.end();
-});
-
-test('Date', function (t) {
- var now = new Date();
- t.equal(inspect(now), String(now), 'Date shows properly');
- t.equal(inspect(new Date(NaN)), 'Invalid Date', 'Invalid Date shows properly');
-
- t.end();
-});
-
-test('RegExps', function (t) {
- t.equal(inspect(/a/g), '/a/g', 'regex shows properly');
- t.equal(inspect(new RegExp('abc', 'i')), '/abc/i', 'new RegExp shows properly');
-
- t.end();
-});