summaryrefslogtreecommitdiff
path: root/src/node_modules/object-is/test
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2021-12-21 16:52:28 +0100
committerMinteck <contact@minteck.org>2021-12-21 16:52:28 +0100
commit46e43f4bde4a35785b4997b81e86cd19f046b69b (patch)
treec53c2f826f777f9d6b2d249dab556feb72a6c3a6 /src/node_modules/object-is/test
downloadlangdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.gz
langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.bz2
langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.zip
Commit
Diffstat (limited to 'src/node_modules/object-is/test')
-rw-r--r--src/node_modules/object-is/test/implementation.js12
-rw-r--r--src/node_modules/object-is/test/index.js12
-rw-r--r--src/node_modules/object-is/test/shimmed.js28
-rw-r--r--src/node_modules/object-is/test/tests.js57
4 files changed, 109 insertions, 0 deletions
diff --git a/src/node_modules/object-is/test/implementation.js b/src/node_modules/object-is/test/implementation.js
new file mode 100644
index 0000000..76de8be
--- /dev/null
+++ b/src/node_modules/object-is/test/implementation.js
@@ -0,0 +1,12 @@
+'use strict';
+
+var implementation = require('../implementation');
+var callBind = require('call-bind');
+var test = require('tape');
+var runTests = require('./tests');
+
+test('as a function', function (t) {
+ runTests(callBind(implementation, Object), t);
+
+ t.end();
+});
diff --git a/src/node_modules/object-is/test/index.js b/src/node_modules/object-is/test/index.js
new file mode 100644
index 0000000..39f34b3
--- /dev/null
+++ b/src/node_modules/object-is/test/index.js
@@ -0,0 +1,12 @@
+'use strict';
+
+var index = require('../');
+var test = require('tape');
+
+var runTests = require('./tests');
+
+test('as a function', function (t) {
+ runTests(index, t);
+
+ t.end();
+});
diff --git a/src/node_modules/object-is/test/shimmed.js b/src/node_modules/object-is/test/shimmed.js
new file mode 100644
index 0000000..eb8de97
--- /dev/null
+++ b/src/node_modules/object-is/test/shimmed.js
@@ -0,0 +1,28 @@
+'use strict';
+
+require('../auto');
+
+var runTests = require('./tests');
+
+var test = require('tape');
+var defineProperties = require('define-properties');
+var callBind = require('call-bind');
+var isEnumerable = Object.prototype.propertyIsEnumerable;
+var functionsHaveNames = require('functions-have-names')();
+
+test('shimmed', function (t) {
+ t.equal(Object.is.length, 2, 'Object.is has a length of 2');
+ t.test('Function name', { skip: !functionsHaveNames }, function (st) {
+ st.equal(Object.is.name, 'is', 'Object.is has name "is"');
+ st.end();
+ });
+
+ t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
+ et.equal(false, isEnumerable.call(Object, 'is'), 'Object.is is not enumerable');
+ et.end();
+ });
+
+ runTests(callBind(Object.is, Object), t);
+
+ t.end();
+});
diff --git a/src/node_modules/object-is/test/tests.js b/src/node_modules/object-is/test/tests.js
new file mode 100644
index 0000000..c9af9f2
--- /dev/null
+++ b/src/node_modules/object-is/test/tests.js
@@ -0,0 +1,57 @@
+'use strict';
+
+var hasSymbols = require('has-symbols')();
+
+module.exports = function runTests(is, t) {
+ t.test('works with primitives', function (st) {
+ st.ok(is(), 'two absent args are the same');
+ st.ok(is(undefined), 'undefined & one absent arg are the same');
+ st.ok(is(undefined, undefined), 'undefined is undefined');
+ st.ok(is(null, null), 'null is null');
+ st.ok(is(true, true), 'true is true');
+ st.ok(is(false, false), 'false is false');
+ st.notOk(is(true, false), 'true is not false');
+ st.end();
+ });
+
+ t.test('works with NaN', function (st) {
+ st.ok(is(NaN, NaN), 'NaN is NaN');
+ st.end();
+ });
+
+ t.test('differentiates zeroes', function (st) {
+ st.ok(is(0, 0), '+0 is +0');
+ st.ok(is(-0, -0), '-0 is -0');
+ st.notOk(is(0, -0), '+0 is not -0');
+ st.end();
+ });
+
+ t.test('nonzero numbers', function (st) {
+ st.ok(is(Infinity, Infinity), 'infinity is infinity');
+ st.ok(is(-Infinity, -Infinity), 'infinity is infinity');
+ st.ok(is(42, 42), '42 is 42');
+ st.notOk(is(42, -42), '42 is not -42');
+ st.end();
+ });
+
+ t.test('strings', function (st) {
+ st.ok(is('', ''), 'empty string is empty string');
+ st.ok(is('foo', 'foo'), 'string is string');
+ st.notOk(is('foo', 'bar'), 'string is not different string');
+ st.end();
+ });
+
+ t.test('objects', function (st) {
+ var obj = {};
+ st.ok(is(obj, obj), 'object is same object');
+ st.notOk(is(obj, {}), 'object is not different object');
+ st.end();
+ });
+
+ t.test('Symbols', { skip: !hasSymbols }, function (st) {
+ st.ok(is(Symbol.iterator, Symbol.iterator), 'Symbol.iterator is itself');
+ st.notOk(is(Symbol(), Symbol()), 'different Symbols are not equal');
+ st.notOk(is(Symbol.iterator, Object(Symbol.iterator)), 'Symbol.iterator is not boxed form of itself');
+ st.end();
+ });
+};