Debian Codegraph @

memoizee/test/plain.js

raw
1 /* eslint id-length: 0 */
2
3 "use strict";
4
5 module.exports = function (t) {
6 return {
7 "": function (a) {
8 var i = 0
9 , fn = function (x) {
10 ++i;
11 return x;
12 }
13 , mfn
14 , y = { toString: function () { return "foo"; } };
15 mfn = t(fn, { primitive: true });
16 a(typeof mfn, "function", "Returns");
17 a(mfn.__memoized__, true, "Marked");
18 a(t(mfn), mfn, "Do not memoize memoized");
19 a(mfn(y), y, "#1");
20 a(mfn("foo"), y, "#2");
21 a(i, 1, "Called once");
22 },
23 "Clear cache": function (a) {
24 var i = 0
25 , fn = function (x, y, z) {
26 ++i;
27 return x + y + z;
28 }
29 , mfn
30 , y = { toString: function () { return "foo"; } };
31 mfn = t(fn, { primitive: true });
32 a(mfn(y, "bar", "zeta"), "foobarzeta", "#1");
33 a(mfn("foo", "bar", "zeta"), "foobarzeta", "#2");
34 a(i, 1, "Called once");
35 mfn.delete("foo", { toString: function () { return "bar"; } }, "zeta");
36 a(mfn(y, "bar", "zeta"), "foobarzeta", "#3");
37 a(i, 2, "Called twice");
38 },
39 };
40 };