aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es5-ext/test/function
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/es5-ext/test/function')
-rw-r--r--node_modules/es5-ext/test/function/#/compose.js15
-rw-r--r--node_modules/es5-ext/test/function/#/copy.js22
-rw-r--r--node_modules/es5-ext/test/function/#/curry.js20
-rw-r--r--node_modules/es5-ext/test/function/#/lock.js7
-rw-r--r--node_modules/es5-ext/test/function/#/not.js11
-rw-r--r--node_modules/es5-ext/test/function/#/partial.js11
-rw-r--r--node_modules/es5-ext/test/function/#/spread.js10
-rw-r--r--node_modules/es5-ext/test/function/#/to-string-tokens.js33
-rw-r--r--node_modules/es5-ext/test/function/_define-length.js14
-rw-r--r--node_modules/es5-ext/test/function/constant.js7
-rw-r--r--node_modules/es5-ext/test/function/identity.js7
-rw-r--r--node_modules/es5-ext/test/function/invoke.js9
-rw-r--r--node_modules/es5-ext/test/function/is-arguments.js13
-rw-r--r--node_modules/es5-ext/test/function/is-function.js8
-rw-r--r--node_modules/es5-ext/test/function/noop.js5
-rw-r--r--node_modules/es5-ext/test/function/pluck.js7
-rw-r--r--node_modules/es5-ext/test/function/valid-function.js22
17 files changed, 221 insertions, 0 deletions
diff --git a/node_modules/es5-ext/test/function/#/compose.js b/node_modules/es5-ext/test/function/#/compose.js
new file mode 100644
index 000000000..433f3b4b1
--- /dev/null
+++ b/node_modules/es5-ext/test/function/#/compose.js
@@ -0,0 +1,15 @@
+"use strict";
+
+var f = function (a, b) {
+ return ["a", arguments.length, a, b];
+}
+ , g = function (a) {
+ return ["b", arguments.length].concat(a);
+}
+ , h = function (a) {
+ return ["c", arguments.length].concat(a);
+};
+
+module.exports = function (t, a) {
+ a.deep(t.call(h, g, f)(1, 2), ["c", 1, "b", 1, "a", 2, 1, 2]);
+};
diff --git a/node_modules/es5-ext/test/function/#/copy.js b/node_modules/es5-ext/test/function/#/copy.js
new file mode 100644
index 000000000..9948f1183
--- /dev/null
+++ b/node_modules/es5-ext/test/function/#/copy.js
@@ -0,0 +1,22 @@
+"use strict";
+
+module.exports = function (t, a) {
+ var foo = "raz", bar = "dwa";
+ // eslint-disable-next-line func-names
+ var fn = function marko (a, b) {
+ return this + a + b + foo + bar;
+ };
+ var result, o = {};
+
+ fn.prototype = o;
+
+ fn.foo = "raz";
+
+ result = t.call(fn);
+
+ a(result.length, fn.length, "Length");
+ a(result.name, fn.name, "Length");
+ a(result.call("marko", "el", "fe"), "markoelferazdwa", "Body");
+ a(result.prototype, fn.prototype, "Prototype");
+ a(result.foo, fn.foo, "Custom property");
+};
diff --git a/node_modules/es5-ext/test/function/#/curry.js b/node_modules/es5-ext/test/function/#/curry.js
new file mode 100644
index 000000000..c30313a0d
--- /dev/null
+++ b/node_modules/es5-ext/test/function/#/curry.js
@@ -0,0 +1,20 @@
+"use strict";
+
+var toArray = require("../../../array/to-array")
+
+ , f = function () {
+ return toArray(arguments);
+};
+
+module.exports = function (t, a) {
+ var x, y = {}, z;
+ a.deep(t.call(f, 0, 1, 2)(3), [], "0 arguments");
+ x = t.call(f, 5, {});
+ a(x.length, 5, "Length #1");
+ z = x(1, 2);
+ a(z.length, 3, "Length #2");
+ z = z(3, 4);
+ a(z.length, 1, "Length #1");
+ a.deep(z(5, 6), [1, 2, 3, 4, 5], "Many arguments");
+ a.deep(x(8, 3)(y, 45)("raz", 6), [8, 3, y, 45, "raz"], "Many arguments #2");
+};
diff --git a/node_modules/es5-ext/test/function/#/lock.js b/node_modules/es5-ext/test/function/#/lock.js
new file mode 100644
index 000000000..08ea9505c
--- /dev/null
+++ b/node_modules/es5-ext/test/function/#/lock.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = function (t, a) {
+ a(t.call(function () {
+ return arguments.length;
+ })(1, 2, 3), 0);
+};
diff --git a/node_modules/es5-ext/test/function/#/not.js b/node_modules/es5-ext/test/function/#/not.js
new file mode 100644
index 000000000..64fff7150
--- /dev/null
+++ b/node_modules/es5-ext/test/function/#/not.js
@@ -0,0 +1,11 @@
+"use strict";
+
+var identity = require("../../../function/identity")
+ , noop = require("../../../function/noop");
+
+module.exports = function (t, a) {
+ a(t.call(identity)(""), true, "Falsy");
+ a(t.call(noop)(), true, "Undefined");
+ a(t.call(identity)({}), false, "Any object");
+ a(t.call(identity)(true), false, "True");
+};
diff --git a/node_modules/es5-ext/test/function/#/partial.js b/node_modules/es5-ext/test/function/#/partial.js
new file mode 100644
index 000000000..7e9428fa9
--- /dev/null
+++ b/node_modules/es5-ext/test/function/#/partial.js
@@ -0,0 +1,11 @@
+"use strict";
+
+var toArray = require("../../../array/to-array")
+
+ , f = function () {
+ return toArray(arguments);
+};
+
+module.exports = function (t, a) {
+ a.deep(t.call(f, 1)(2, 3), [1, 2, 3]);
+};
diff --git a/node_modules/es5-ext/test/function/#/spread.js b/node_modules/es5-ext/test/function/#/spread.js
new file mode 100644
index 000000000..d082fcabc
--- /dev/null
+++ b/node_modules/es5-ext/test/function/#/spread.js
@@ -0,0 +1,10 @@
+"use strict";
+
+var f = function (a, b) {
+ return this[a] + this[b];
+}
+ , o = { a: 3, b: 4 };
+
+module.exports = function (t, a) {
+ a(t.call(f).call(o, ["a", "b"]), 7);
+};
diff --git a/node_modules/es5-ext/test/function/#/to-string-tokens.js b/node_modules/es5-ext/test/function/#/to-string-tokens.js
new file mode 100644
index 000000000..0691cc394
--- /dev/null
+++ b/node_modules/es5-ext/test/function/#/to-string-tokens.js
@@ -0,0 +1,33 @@
+/* eslint no-eval: "off" */
+
+"use strict";
+
+module.exports = function (t, a) {
+ a.deep(
+ t.call(function (a, b) {
+ return this[a] + this[b];
+ }),
+ { args: "a, b", body: "\n\t\t\treturn this[a] + this[b];\n\t\t" }
+ );
+ a.deep(t.call(function () {}), { args: "", body: "" });
+ // eslint-disable-next-line no-unused-vars
+ a.deep(t.call(function (raz) {}), { args: "raz", body: "" });
+ a.deep(
+ t.call(function () {
+ Object();
+ }),
+ { args: "", body: "\n\t\t\tObject();\n\t\t" }
+ );
+
+ try {
+ eval("(() => {})");
+ } catch (e) {
+ // Non ES2015 env
+ return;
+ }
+
+ a.deep(t.call(eval("(() => {})")), { args: "", body: "" });
+ a.deep(t.call(eval("((elo) => foo)")), { args: "elo", body: "foo" });
+ a.deep(t.call(eval("(elo => foo)")), { args: "elo", body: "foo" });
+ a.deep(t.call(eval("((elo, bar) => foo())")), { args: "elo, bar", body: "foo()" });
+};
diff --git a/node_modules/es5-ext/test/function/_define-length.js b/node_modules/es5-ext/test/function/_define-length.js
new file mode 100644
index 000000000..324e273c0
--- /dev/null
+++ b/node_modules/es5-ext/test/function/_define-length.js
@@ -0,0 +1,14 @@
+"use strict";
+
+module.exports = function (t, a) {
+ var foo = "raz", bar = "dwa"
+ , fn = function (a, b) {
+ return this + a + b + foo + bar;
+}
+ , result;
+
+ result = t(fn, 3);
+ a(result.call("marko", "el", "fe"), "markoelferazdwa", "Content");
+ a(result.length, 3, "Length");
+ a(result.prototype, fn.prototype, "Prototype");
+};
diff --git a/node_modules/es5-ext/test/function/constant.js b/node_modules/es5-ext/test/function/constant.js
new file mode 100644
index 000000000..4ba2d8983
--- /dev/null
+++ b/node_modules/es5-ext/test/function/constant.js
@@ -0,0 +1,7 @@
+"use strict";
+
+var o = {};
+
+module.exports = function (t, a) {
+ a(t(o)(), o);
+};
diff --git a/node_modules/es5-ext/test/function/identity.js b/node_modules/es5-ext/test/function/identity.js
new file mode 100644
index 000000000..a5b0b1bc9
--- /dev/null
+++ b/node_modules/es5-ext/test/function/identity.js
@@ -0,0 +1,7 @@
+"use strict";
+
+var o = {};
+
+module.exports = function (t, a) {
+ a(t(o), o);
+};
diff --git a/node_modules/es5-ext/test/function/invoke.js b/node_modules/es5-ext/test/function/invoke.js
new file mode 100644
index 000000000..6268f47e9
--- /dev/null
+++ b/node_modules/es5-ext/test/function/invoke.js
@@ -0,0 +1,9 @@
+"use strict";
+
+var constant = require("../../function/constant")
+
+ , o = { b: constant("c") };
+
+module.exports = function (t, a) {
+ a(t("b")(o), "c");
+};
diff --git a/node_modules/es5-ext/test/function/is-arguments.js b/node_modules/es5-ext/test/function/is-arguments.js
new file mode 100644
index 000000000..5bd54ac7e
--- /dev/null
+++ b/node_modules/es5-ext/test/function/is-arguments.js
@@ -0,0 +1,13 @@
+"use strict";
+
+module.exports = function (t, a) {
+ var args, dummy;
+ args = (function () {
+ return arguments;
+}());
+ dummy = { 0: 1, 1: 2 };
+ Object.defineProperty(dummy, "length", { value: 2 });
+ a(t(args), true, "Arguments");
+ a(t(dummy), false, "Dummy");
+ a(t([]), false, "Array");
+};
diff --git a/node_modules/es5-ext/test/function/is-function.js b/node_modules/es5-ext/test/function/is-function.js
new file mode 100644
index 000000000..fe8979851
--- /dev/null
+++ b/node_modules/es5-ext/test/function/is-function.js
@@ -0,0 +1,8 @@
+"use strict";
+
+var o = { call: Function.prototype.call, apply: Function.prototype.apply };
+
+module.exports = function (t, a) {
+ a(t(function () {}), true, "Function is function");
+ a(t(o), false, "Plain object is not function");
+};
diff --git a/node_modules/es5-ext/test/function/noop.js b/node_modules/es5-ext/test/function/noop.js
new file mode 100644
index 000000000..34de85ab6
--- /dev/null
+++ b/node_modules/es5-ext/test/function/noop.js
@@ -0,0 +1,5 @@
+"use strict";
+
+module.exports = function (t, a) {
+ a(typeof t(1, 2, 3), "undefined");
+};
diff --git a/node_modules/es5-ext/test/function/pluck.js b/node_modules/es5-ext/test/function/pluck.js
new file mode 100644
index 000000000..f8954c59d
--- /dev/null
+++ b/node_modules/es5-ext/test/function/pluck.js
@@ -0,0 +1,7 @@
+"use strict";
+
+var o = { foo: "bar" };
+
+module.exports = function (t, a) {
+ a(t("foo")(o), o.foo);
+};
diff --git a/node_modules/es5-ext/test/function/valid-function.js b/node_modules/es5-ext/test/function/valid-function.js
new file mode 100644
index 000000000..30c036084
--- /dev/null
+++ b/node_modules/es5-ext/test/function/valid-function.js
@@ -0,0 +1,22 @@
+"use strict";
+
+module.exports = function (t, a) {
+ var f = function () {};
+ a(t(f), f, "Function");
+ // eslint-disable-next-line no-new-func
+ f = new Function();
+ a(t(f), f, "Function");
+ a.throws(function () {
+ t({});
+ }, "Object");
+ a.throws(function () {
+ t(/re/);
+ }, "RegExp");
+ a.throws(function () {
+ t({
+ call: function () {
+ return 20;
+ }
+ });
+ }, "Plain object");
+};