mirror of
https://github.com/morluto/rea
synced 2026-10-27 14:42:18 -04:00
fix(semantics): preserve direct promise ownership boundaries (#758)
Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
committed by
GitHub
parent
66c26f280b
commit
e1ca412757
@@ -286,3 +286,27 @@ const graphFor = (source: string) => {
|
||||
analysis,
|
||||
});
|
||||
};
|
||||
|
||||
it.each([
|
||||
"const value = consume(Promise.resolve(1));",
|
||||
"async function run() { await consume(Promise.resolve(1)); }",
|
||||
"function run() { return consume(Promise.resolve(1)); }",
|
||||
"const value = Promise.all([{ promise: Promise.resolve(1) }]);",
|
||||
])(
|
||||
"does not claim direct Promise ownership through an enclosing expression: %s",
|
||||
(source) => {
|
||||
const graph = graphFor(source);
|
||||
const promise = graph.nodes.find(
|
||||
({ kind, properties }) =>
|
||||
kind === "promise" && properties.method === "resolve",
|
||||
);
|
||||
expect(promise?.properties.ownership).toBe("unknown");
|
||||
expect(
|
||||
graph.relations.filter(
|
||||
({ target_node_id, relation }) =>
|
||||
target_node_id === promise?.node_id &&
|
||||
["owns", "awaits", "returns-task", "aggregates"].includes(relation),
|
||||
),
|
||||
).toEqual([]);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user