aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es5-ext/test
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/es5-ext/test')
-rw-r--r--node_modules/es5-ext/test/.eslintrc.json23
-rw-r--r--node_modules/es5-ext/test/array/#/is-empty.js8
-rw-r--r--node_modules/es5-ext/test/array/to-array.js26
-rw-r--r--node_modules/es5-ext/test/date/ensure-time-value.js14
-rw-r--r--node_modules/es5-ext/test/date/is-time-value.js15
-rw-r--r--node_modules/es5-ext/test/function/#/copy.js2
-rw-r--r--node_modules/es5-ext/test/iterable/is.js12
-rw-r--r--node_modules/es5-ext/test/object/assign-deep.js15
-rw-r--r--node_modules/es5-ext/test/object/copy-deep.js20
-rw-r--r--node_modules/es5-ext/test/object/ensure-array.js55
-rw-r--r--node_modules/es5-ext/test/object/is-array-like.js12
-rw-r--r--node_modules/es5-ext/test/object/is-plain-function.js42
-rw-r--r--node_modules/es5-ext/test/string/#/repeat/shim.js1
-rw-r--r--node_modules/es5-ext/test/string/random.js13
-rw-r--r--node_modules/es5-ext/test/to-short-string-representation.js23
15 files changed, 247 insertions, 34 deletions
diff --git a/node_modules/es5-ext/test/.eslintrc.json b/node_modules/es5-ext/test/.eslintrc.json
index 3e9128d4c..3ac4585bd 100644
--- a/node_modules/es5-ext/test/.eslintrc.json
+++ b/node_modules/es5-ext/test/.eslintrc.json
@@ -1,13 +1,14 @@
{
- "globals": {
- "Symbol": true
- },
- "rules": {
- "consistent-this": "off",
- "id-length": "off",
- "no-empty-function": "off",
- "no-new-wrappers": "off",
- "no-prototype-builtins": "off",
- "no-shadow": "off"
- }
+ "globals": {
+ "Symbol": true
+ },
+ "rules": {
+ "consistent-this": "off",
+ "id-length": "off",
+ "no-empty-function": "off",
+ "no-eval": "off",
+ "no-new-wrappers": "off",
+ "no-prototype-builtins": "off",
+ "no-shadow": "off"
+ }
}
diff --git a/node_modules/es5-ext/test/array/#/is-empty.js b/node_modules/es5-ext/test/array/#/is-empty.js
new file mode 100644
index 000000000..1e1c097b3
--- /dev/null
+++ b/node_modules/es5-ext/test/array/#/is-empty.js
@@ -0,0 +1,8 @@
+"use strict";
+
+module.exports = function (t, a) {
+ var x = {};
+ a(t.call([]), true, "Empty");
+ a(t.call({ length: 0 }), true, "Empty lists");
+ a(t.call([1, x, "raz"]), false, "Non empty");
+};
diff --git a/node_modules/es5-ext/test/array/to-array.js b/node_modules/es5-ext/test/array/to-array.js
index 4e93ad5db..a1f10a4a4 100644
--- a/node_modules/es5-ext/test/array/to-array.js
+++ b/node_modules/es5-ext/test/array/to-array.js
@@ -4,14 +4,24 @@ module.exports = function (t, a) {
var o = [1, 2, 3];
a(t(o), o, "Array");
a.deep(t("12r3v"), ["1", "2", "r", "3", "v"], "String");
- a.deep(t((function () {
- return arguments;
-}(3, o, "raz"))),
- [3, o, "raz"], "Arguments");
- a.deep(t((function () {
- return arguments;
-}(3))), [3],
- "Arguments with one numeric value");
+ a.deep(
+ t(
+ (function () {
+ return arguments;
+ })(3, o, "raz")
+ ),
+ [3, o, "raz"],
+ "Arguments"
+ );
+ a.deep(
+ t(
+ (function () {
+ return arguments;
+ })(3)
+ ),
+ [3],
+ "Arguments with one numeric value"
+ );
a.deep(t({ 0: "raz", 1: "dwa", length: 2 }), ["raz", "dwa"], "Other");
};
diff --git a/node_modules/es5-ext/test/date/ensure-time-value.js b/node_modules/es5-ext/test/date/ensure-time-value.js
new file mode 100644
index 000000000..39ddc23c4
--- /dev/null
+++ b/node_modules/es5-ext/test/date/ensure-time-value.js
@@ -0,0 +1,14 @@
+"use strict";
+
+module.exports = function (t, a) {
+ a(t(12), 12, "Number in range");
+ a(t(12.23), 12, "Rounds number in range");
+ a(t(-12.63), -12, "Rounds negative number in range");
+ a.throws(
+ function () {
+ t(NaN);
+ },
+ TypeError,
+ "Throws on invalid"
+ );
+};
diff --git a/node_modules/es5-ext/test/date/is-time-value.js b/node_modules/es5-ext/test/date/is-time-value.js
new file mode 100644
index 000000000..a21677c06
--- /dev/null
+++ b/node_modules/es5-ext/test/date/is-time-value.js
@@ -0,0 +1,15 @@
+"use strict";
+
+module.exports = function (t, a) {
+ a(t("arar"), false, "String");
+ a(t(12), true, "Number in range");
+ a(t(true), true, "Boolean");
+ a(t(new Date()), true, "Date");
+ a(t({}), false, "Plain object");
+ a(t(NaN), false, "NaN");
+ a(t(Infinity), false, "Infinity");
+ a(t(8.64e17), false, "Beyond range");
+ a(t(8.64e15), true, "Below range");
+ a(t(-8.64e17), false, "Negative beyond range");
+ a(t(-8.64e15), true, "Negative below range");
+};
diff --git a/node_modules/es5-ext/test/function/#/copy.js b/node_modules/es5-ext/test/function/#/copy.js
index 9948f1183..e7988ce74 100644
--- a/node_modules/es5-ext/test/function/#/copy.js
+++ b/node_modules/es5-ext/test/function/#/copy.js
@@ -3,7 +3,7 @@
module.exports = function (t, a) {
var foo = "raz", bar = "dwa";
// eslint-disable-next-line func-names
- var fn = function marko (a, b) {
+ var fn = function marko(a, b) {
return this + a + b + foo + bar;
};
var result, o = {};
diff --git a/node_modules/es5-ext/test/iterable/is.js b/node_modules/es5-ext/test/iterable/is.js
index 8c3158b22..04d34a83c 100644
--- a/node_modules/es5-ext/test/iterable/is.js
+++ b/node_modules/es5-ext/test/iterable/is.js
@@ -6,9 +6,15 @@ module.exports = function (t, a) {
var x;
a(t([]), true, "Array");
a(t(""), true, "String");
- a(t((function () {
- return arguments;
-}())), true, "Arguments");
+ a(
+ t(
+ (function () {
+ return arguments;
+ })()
+ ),
+ true,
+ "Arguments"
+ );
a(t({ length: 0 }), true, "List object");
a(t(function () {}), false, "Function");
a(t({}), false, "Plain object");
diff --git a/node_modules/es5-ext/test/object/assign-deep.js b/node_modules/es5-ext/test/object/assign-deep.js
new file mode 100644
index 000000000..071eeb739
--- /dev/null
+++ b/node_modules/es5-ext/test/object/assign-deep.js
@@ -0,0 +1,15 @@
+"use strict";
+
+module.exports = function (t, a) {
+ var o1 = { a: 1, b: 2 }, o2 = { b: 3, c: 4 };
+
+ a(t(o1, o2), o1, "Returns self");
+ a.deep(o1, { a: 1, b: 3, c: 4 }, "Single: content");
+
+ a.deep(t({}, o1, o2), { a: 1, b: 3, c: 4 }, "Multi argument");
+
+ var obj1 = { foo: { bar: 3, marko: true } }
+ , obj2 = { foo: { elo: 12, marko: false }, miszka: [23] };
+ a.deep(t({}, obj1, obj2), { foo: { bar: 3, marko: false, elo: 12 }, miszka: [23] });
+ a(t(true), true);
+};
diff --git a/node_modules/es5-ext/test/object/copy-deep.js b/node_modules/es5-ext/test/object/copy-deep.js
index 2dcbc3ab9..93813830f 100644
--- a/node_modules/es5-ext/test/object/copy-deep.js
+++ b/node_modules/es5-ext/test/object/copy-deep.js
@@ -3,19 +3,22 @@
var stringify = JSON.stringify;
module.exports = function (t, a) {
- var o = { 1: "raz", 2: "dwa", 3: "trzy" }
- , no = t(o);
+ var o = { 1: "raz", 2: "dwa", 3: "trzy" }, no = t(o);
a.not(no, o, "Return different object");
a(stringify(no), stringify(o), "Match properties and values");
- o = { foo: "bar",
-raz: { dwa: "dwa",
- trzy: { cztery: "pięć", sześć: "siedem" },
-osiem: {},
- dziewięć: function () { } },
+ o = {
+ foo: "bar",
+ raz: {
+ dwa: "dwa",
+ trzy: { cztery: "pięć", sześć: "siedem" },
+ osiem: {},
+ dziewięć: function () {}
+ },
dziesięć: 10,
-jedenaście: ["raz", ["dwa", "trzy", { elo: "true" }]] };
+ jedenaście: ["raz", ["dwa", "trzy", { elo: "true" }]]
+ };
o.raz.rec = o;
no = t(o);
@@ -28,4 +31,5 @@ jedenaście: ["raz", ["dwa", "trzy", { elo: "true" }]] };
a.not(o["jedenaście"], no["jedenaście"]);
a.not(o["jedenaście"][1], no["jedenaście"][1]);
a.not(o["jedenaście"][1][2], no["jedenaście"][1][2]);
+ a(t(true), true);
};
diff --git a/node_modules/es5-ext/test/object/ensure-array.js b/node_modules/es5-ext/test/object/ensure-array.js
new file mode 100644
index 000000000..fd3c32c97
--- /dev/null
+++ b/node_modules/es5-ext/test/object/ensure-array.js
@@ -0,0 +1,55 @@
+"use strict";
+
+module.exports = function (t, a) {
+ var arr = [];
+ a(t(arr), arr, "Array");
+ a(t(""), "", "String");
+ var args = (function () {
+ return arguments;
+ }());
+ a(t(args), args, "Arguments");
+ var arrayLike = { length: 0 };
+ a(t(arrayLike), arrayLike, "Array like");
+ a.throws(
+ function () {
+ t(function () {});
+ },
+ TypeError,
+ "Function"
+ );
+ a.throws(
+ function () {
+ t({});
+ },
+ TypeError,
+ "Plain object"
+ );
+ a.throws(
+ function () {
+ t(/raz/);
+ },
+ TypeError,
+ "Regexp"
+ );
+ a.throws(
+ function () {
+ t();
+ },
+ TypeError,
+ "No argument"
+ );
+ a.throws(
+ function () {
+ t(null);
+ },
+ TypeError,
+ "Null"
+ );
+ a.throws(
+ function () {
+ t(undefined);
+ },
+ TypeError,
+ "Undefined"
+ );
+};
diff --git a/node_modules/es5-ext/test/object/is-array-like.js b/node_modules/es5-ext/test/object/is-array-like.js
index c50ef1d12..50f5ce596 100644
--- a/node_modules/es5-ext/test/object/is-array-like.js
+++ b/node_modules/es5-ext/test/object/is-array-like.js
@@ -3,9 +3,15 @@
module.exports = function (t, a) {
a(t([]), true, "Array");
a(t(""), true, "String");
- a(t((function () {
- return arguments;
-}())), true, "Arguments");
+ a(
+ t(
+ (function () {
+ return arguments;
+ })()
+ ),
+ true,
+ "Arguments"
+ );
a(t({ length: 0 }), true, "List object");
a(t(function () {}), false, "Function");
a(t({}), false, "Plain object");
diff --git a/node_modules/es5-ext/test/object/is-plain-function.js b/node_modules/es5-ext/test/object/is-plain-function.js
new file mode 100644
index 000000000..9c1f5ed38
--- /dev/null
+++ b/node_modules/es5-ext/test/object/is-plain-function.js
@@ -0,0 +1,42 @@
+"use strict";
+
+var setPrototypeOf = require("../../object/set-prototype-of");
+
+module.exports = function (t, a) {
+ a(t(function () {}), true, "Function");
+ a(t({}), false, "Object");
+ a(t(), false, "Undefined");
+ a(t(null), false, "Null");
+ if (setPrototypeOf) {
+ a(
+ t(Object.setPrototypeOf(function () {}, Object.prototype)),
+ false,
+ "Function with non-function prototype"
+ );
+ }
+ var arrowfn;
+ try {
+ arrowfn = eval("(() => {})");
+ } catch (e) {}
+ if (arrowfn) {
+ a(t(arrowfn), true, "Arrow function");
+ }
+
+ var classFn;
+ try {
+ classFn = eval("(class {})");
+ } catch (e) {}
+ if (classFn) {
+ a(t(classFn), false, "Class");
+ }
+
+ var commentedClassFn;
+ try {
+ // Follows issue reported to ljhard/is-callable project:
+ // https://github.com/ljharb/is-callable/issues/4
+ commentedClassFn = eval("(class/*kkk*/\n//blah\n Bar\n//blah\n {})");
+ } catch (e) {}
+ if (commentedClassFn) {
+ a(t(commentedClassFn, false, "Class"), false, "Class with comments");
+ }
+};
diff --git a/node_modules/es5-ext/test/string/#/repeat/shim.js b/node_modules/es5-ext/test/string/#/repeat/shim.js
index 4d328390a..c5848840c 100644
--- a/node_modules/es5-ext/test/string/#/repeat/shim.js
+++ b/node_modules/es5-ext/test/string/#/repeat/shim.js
@@ -8,4 +8,5 @@ module.exports = function (t, a) {
a(t.call("raz", 3), "razrazraz", "Many chars");
a(t.call("raz", 3), "razrazraz", "Many chars");
a(t.call("razfoobar", 5), "razfoobarrazfoobarrazfoobarrazfoobarrazfoobar", "Many chars");
+ a(t.call("a", 300).length, 300);
};
diff --git a/node_modules/es5-ext/test/string/random.js b/node_modules/es5-ext/test/string/random.js
new file mode 100644
index 000000000..3fa44ca5b
--- /dev/null
+++ b/node_modules/es5-ext/test/string/random.js
@@ -0,0 +1,13 @@
+"use strict";
+
+var isValidFormat = RegExp.prototype.test.bind(/^[a-z0-9]+$/);
+
+module.exports = function (t, a) {
+ a(typeof t(), "string");
+ a.ok(t().length > 7);
+ a.not(t({ isUnique: true }), t({ isUnique: true }));
+ a.ok(isValidFormat(t()));
+ a(t({ length: 1 }).length, 1);
+ a(t({ length: 100 }).length, 100);
+ a(t({ length: 0 }), "");
+};
diff --git a/node_modules/es5-ext/test/to-short-string-representation.js b/node_modules/es5-ext/test/to-short-string-representation.js
new file mode 100644
index 000000000..ea9a06d89
--- /dev/null
+++ b/node_modules/es5-ext/test/to-short-string-representation.js
@@ -0,0 +1,23 @@
+"use strict";
+
+var repeat = require("../string/#/repeat");
+
+module.exports = function (t, a) {
+ a(t(), "undefined");
+ a(t(null), "null");
+ a(t(10), "10");
+ a(t("str"), "str");
+ a(
+ t({
+ toString: function () {
+ return "miszka";
+ }
+ }),
+ "miszka"
+ );
+ // eslint-disable-next-line symbol-description
+ if (typeof Symbol === "function") a(t(Symbol()), "Symbol()");
+ a(t(Object.create(null)), "<non-stringifiable value>");
+ a(t(repeat.call("a", 300)), repeat.call("a", 99) + "…");
+ a(t("mar\ntoo\nfar"), "mar\\ntoo\\nfar");
+};