aboutsummaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/is-symbol/test/index.js
diff options
context:
space:
mode:
authorisaacs <nope@not.real>2019-07-03 10:23:19 -0700
committerRich Trott <rtrott@gmail.com>2019-07-18 15:12:49 -0700
commit1721034a40c5e7a0a334701dc36153adee3f27e5 (patch)
tree7b2ce5a0c5d67d2e1d817fc548571250e8c1a305 /deps/npm/node_modules/is-symbol/test/index.js
parent6df7b6a4f9cb64d298e7fd0691c4d09679872922 (diff)
downloadandroid-node-v8-1721034a40c5e7a0a334701dc36153adee3f27e5.tar.gz
android-node-v8-1721034a40c5e7a0a334701dc36153adee3f27e5.tar.bz2
android-node-v8-1721034a40c5e7a0a334701dc36153adee3f27e5.zip
deps: upgrade npm to 6.10.0
PR-URL: https://github.com/nodejs/node/pull/28525 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/is-symbol/test/index.js')
-rw-r--r--deps/npm/node_modules/is-symbol/test/index.js91
1 files changed, 91 insertions, 0 deletions
diff --git a/deps/npm/node_modules/is-symbol/test/index.js b/deps/npm/node_modules/is-symbol/test/index.js
new file mode 100644
index 0000000000..46dfa439d9
--- /dev/null
+++ b/deps/npm/node_modules/is-symbol/test/index.js
@@ -0,0 +1,91 @@
+'use strict';
+
+var test = require('tape');
+var isSymbol = require('../index');
+
+var forEach = function (arr, func) {
+ var i;
+ for (i = 0; i < arr.length; ++i) {
+ func(arr[i], i, arr);
+ }
+};
+
+var hasSymbols = require('has-symbols')();
+var inspect = require('object-inspect');
+var debug = function (v, m) { return inspect(v) + ' ' + m; };
+
+test('non-symbol values', function (t) {
+ var nonSymbols = [
+ true,
+ false,
+ Object(true),
+ Object(false),
+ null,
+ undefined,
+ {},
+ [],
+ /a/g,
+ 'string',
+ 42,
+ new Date(),
+ function () {},
+ NaN
+ ];
+ t.plan(nonSymbols.length);
+ forEach(nonSymbols, function (nonSymbol) {
+ t.equal(false, isSymbol(nonSymbol), debug(nonSymbol, 'is not a symbol'));
+ });
+ t.end();
+});
+
+test('faked symbol values', function (t) {
+ t.test('real symbol valueOf', { skip: !hasSymbols }, function (st) {
+ var fakeSymbol = { valueOf: function () { return Symbol('foo'); } };
+ st.equal(false, isSymbol(fakeSymbol), 'object with valueOf returning a symbol is not a symbol');
+ st.end();
+ });
+
+ t.test('faked @@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (st) {
+ var fakeSymbol = { valueOf: function () { return Symbol('foo'); } };
+ fakeSymbol[Symbol.toStringTag] = 'Symbol';
+ st.equal(false, isSymbol(fakeSymbol), 'object with fake Symbol @@toStringTag and valueOf returning a symbol is not a symbol');
+ var notSoFakeSymbol = { valueOf: function () { return 42; } };
+ notSoFakeSymbol[Symbol.toStringTag] = 'Symbol';
+ st.equal(false, isSymbol(notSoFakeSymbol), 'object with fake Symbol @@toStringTag and valueOf not returning a symbol is not a symbol');
+ st.end();
+ });
+
+ var fakeSymbolString = { toString: function () { return 'Symbol(foo)'; } };
+ t.equal(false, isSymbol(fakeSymbolString), 'object with toString returning Symbol(foo) is not a symbol');
+
+ t.end();
+});
+
+test('Symbol support', { skip: !hasSymbols }, function (t) {
+ t.test('well-known Symbols', function (st) {
+ var isWellKnown = function filterer(name) {
+ return name !== 'for' && name !== 'keyFor' && !(name in filterer);
+ };
+ var wellKnownSymbols = Object.getOwnPropertyNames(Symbol).filter(isWellKnown);
+ wellKnownSymbols.forEach(function (name) {
+ var sym = Symbol[name];
+ st.equal(true, isSymbol(sym), debug(sym, ' is a symbol'));
+ });
+ st.end();
+ });
+
+ t.test('user-created symbols', function (st) {
+ var symbols = [
+ Symbol(),
+ Symbol('foo'),
+ Symbol['for']('foo'),
+ Object(Symbol('object'))
+ ];
+ symbols.forEach(function (sym) {
+ st.equal(true, isSymbol(sym), debug(sym, ' is a symbol'));
+ });
+ st.end();
+ });
+
+ t.end();
+});