aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es5-ext/test/object
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/es5-ext/test/object')
-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
5 files changed, 133 insertions, 11 deletions
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");
+ }
+};