thing-contract-ts: present's slot names are held by a test, and its forwarded getters are not enumerable (Stryker survivors)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9e698c86df
commit
47fba57a6d
2 changed files with 12 additions and 2 deletions
|
|
@ -73,8 +73,8 @@ export function present(codec: Codec<unknown>): Codec<unknown> {
|
|||
if (!("names" in codec)) return held;
|
||||
const record = codec as SlotsCodec<object>;
|
||||
return Object.defineProperties(held, {
|
||||
names: { get: () => record.names, enumerable: true },
|
||||
members: { get: () => record.members, enumerable: true },
|
||||
names: { get: () => record.names },
|
||||
members: { get: () => record.members },
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,3 +53,13 @@ test("TextInputNode's slot 2 is inputKind, and the name set holds no Kind-only s
|
|||
assert.ok(names.has(`${NS}InputKind`));
|
||||
assert.equal([...names].filter((name) => name.endsWith(".Kind")).length, 0);
|
||||
});
|
||||
|
||||
test("a record keeps its slot names and members through presence, and a union, a list and a leaf carry none", () => {
|
||||
const shapes = codecs as unknown as Record<string, object>;
|
||||
for (const record of ["boxNode", "bind", "nodeCommon", "rgba", "dimensionPx"]) {
|
||||
assert.ok("names" in shapes[record] && "members" in shapes[record], record);
|
||||
}
|
||||
for (const other of ["node", "memberStep", "dimension", "colorRef"]) {
|
||||
assert.ok(!("names" in shapes[other]) && !("members" in shapes[other]), other);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue