mirror of
https://github.com/morluto/rea.git
synced 2026-11-03 05:16:16 +00:00
test(javascript): cover returned object scaling
This commit is contained in:
1 parent
47947eb01c
commit
b973b1b1ec
1 file changed
+51
@@ -608,6 +608,57 @@ describe("property mutation collection on minified bundles", () => {
|
||||
],
|
||||
});
|
||||
}, 30000);
|
||||
|
||||
it("indexes many returned object methods instead of rescanning the object", () => {
|
||||
const methods = Array.from(
|
||||
{ length: 2000 },
|
||||
(_, index) => `m${index}() { return shared; }`,
|
||||
).join(",");
|
||||
const writes = Array.from(
|
||||
{ length: 2000 },
|
||||
(_, index) => `box.m${index}().p${index} = ${index};`,
|
||||
).join(" ");
|
||||
const value = resultValue(
|
||||
`const shared = { token: "TOKEN" }; const box = { ${methods} }; ${writes} return shared.token;`,
|
||||
);
|
||||
expect(value?.status).toBe("unknown");
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
describe("results of methods on an escaped receiver", () => {
|
||||
it("makes every method's distinct result uncertain, not only the called one", () => {
|
||||
expect(
|
||||
resultValue(
|
||||
'const first = { t: "A" }; const second = { t: "B" }; const kept = { t: "C" }; const box = { a() { return first; }, b() { return second; }, c() { return first; } }; box.a(); return [first.t, second.t, kept.t];',
|
||||
),
|
||||
).toMatchObject({
|
||||
status: "array",
|
||||
items: [
|
||||
{ value: { status: "unknown" } },
|
||||
{ value: { status: "unknown" } },
|
||||
{ value: { status: "literal", value: "C" } },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps a shared result uncertain across a wide escaped receiver (#1495)", () => {
|
||||
const count = 2000;
|
||||
const methods = Array.from(
|
||||
{ length: count },
|
||||
(_, index) => `m${index}() { return shared; },`,
|
||||
).join(" ");
|
||||
const calls = Array.from(
|
||||
{ length: count },
|
||||
(_, index) => `box.m${index}().p${index} = ${index};`,
|
||||
).join(" ");
|
||||
const value = resultValue(
|
||||
`const shared = { token: "TOKEN" }; const box = { ${methods} }; ${calls} return [shared.token];`,
|
||||
);
|
||||
expect(value).toMatchObject({
|
||||
status: "array",
|
||||
items: [{ value: { status: "unknown" } }],
|
||||
});
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
describe("results of methods on an escaped receiver", () => {
|
||||
|
||||
Reference in new issue
Block a user