|
| 1 | +/** |
| 2 | + * @vitest-environment jsdom |
| 3 | + */ |
| 4 | +// async-gen seed 3289 #1831 (E1, E9): a grouped and a split leaf, and a |
| 5 | +// leaf reading `latest()` through a memo, show the same screen (F-1, F-12). |
| 6 | +// `m2 = memo(latest(m0) + m1)` has no value yet when `m0`'s first load |
| 7 | +// lands in a flush whose transaction only `latest()` reads opened; its |
| 8 | +// first answer is nobody's hold (D-6), so it reads `m1`'s screen, not the |
| 9 | +// staging (D-22's frame read is for a pass that has a value to re-derive |
| 10 | +// on). Reading the staging there committed an answer that threw later, and |
| 11 | +// the grouped leaf ended on `[ROOT-E]` where the split one shows `[F]`. |
| 12 | +import { expect, test } from "vitest"; |
| 13 | +import fc from "fast-check"; |
| 14 | +import { runScenario } from "./run.js"; |
| 15 | +import { scenarioArb } from "./scenario.js"; |
| 16 | + |
| 17 | +const minimized = { |
| 18 | + signals: [0], |
| 19 | + memos: [ |
| 20 | + { async: true, deps: [{ src: { k: "s", i: 0 }, how: "plain" }], poison: null }, |
| 21 | + { |
| 22 | + async: false, |
| 23 | + deps: [ |
| 24 | + { src: { k: "s", i: 0 }, how: "plain" }, |
| 25 | + { src: { k: "m", i: 0 }, how: "latest" } |
| 26 | + ], |
| 27 | + poison: 0 |
| 28 | + }, |
| 29 | + { |
| 30 | + async: false, |
| 31 | + deps: [ |
| 32 | + { src: { k: "m", i: 0 }, how: "latest" }, |
| 33 | + { src: { k: "m", i: 1 }, how: "plain" } |
| 34 | + ], |
| 35 | + poison: 1 |
| 36 | + } |
| 37 | + ], |
| 38 | + tree: { |
| 39 | + t: "show", |
| 40 | + when: { how: "pending", src: { k: "m", i: 0 } }, |
| 41 | + child: { |
| 42 | + t: "leaf", |
| 43 | + text: [], |
| 44 | + attrs: [ |
| 45 | + { how: "latest", src: { k: "m", i: 2 } }, |
| 46 | + { how: "plain", src: { k: "m", i: 0 } } |
| 47 | + ], |
| 48 | + grouped: true |
| 49 | + }, |
| 50 | + fallback: true |
| 51 | + }, |
| 52 | + steps: [{ t: "settle", pick: 5 }, { t: "task" }, { t: "write", s: 0, v: 1 }, { t: "task" }] |
| 53 | +} as any; |
| 54 | + |
| 55 | +test("minimized: grouped and split attributes show the same screens, ending on [F]", async () => { |
| 56 | + const grouped = await runScenario(minimized, { grouped: true }); |
| 57 | + const split = await runScenario(minimized, { split: true }); |
| 58 | + expect(grouped.screens).toEqual(split.screens); |
| 59 | + expect(grouped.screens.at(-1)).toBe("[F]"); |
| 60 | +}); |
| 61 | + |
| 62 | +test("the generated case: grouped, split, default and latest-through-a-memo agree", async () => { |
| 63 | + const sc = fc.sample(scenarioArb(), { seed: 3289, numRuns: 1832 })[1831]; |
| 64 | + const base = await runScenario(sc, {}); |
| 65 | + for (const v of [{ grouped: true }, { split: true }, { latestDerive: true }]) |
| 66 | + expect((await runScenario(sc, v)).screens).toEqual(base.screens); |
| 67 | +}); |
0 commit comments