mirror of
https://github.com/morluto/rea.git
synced 2026-11-07 23:36:41 +00:00
fix(javascript): preserve semantic uncertainty and lexical ownership
This commit is contained in:
1 parent
9fe54c4073
commit
896696b2e7
16 files changed
+525
-20
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { analyzeJavaScriptSemantics } from "./javascriptSemanticAnalysis.js";
|
||||
|
||||
const normalizedSyntaxFingerprint = (source: string): string => {
|
||||
const [fingerprint] = analyzeJavaScriptSemantics(source).functionFingerprints;
|
||||
expect(fingerprint?.status).toBe("complete");
|
||||
return fingerprint?.components.normalizedAstSha256 ?? "";
|
||||
};
|
||||
|
||||
it("distinguishes yielding an iterator result from delegating to the iterator", () => {
|
||||
expect(
|
||||
normalizedSyntaxFingerprint("function* sample(gen) { yield* gen(); }"),
|
||||
).not.toBe(
|
||||
normalizedSyntaxFingerprint("function* sample(gen) { yield gen(); }"),
|
||||
);
|
||||
});
|
||||
|
||||
it("distinguishes returned prefix and postfix updates", () => {
|
||||
expect(
|
||||
normalizedSyntaxFingerprint("function sample(i) { return ++i; }"),
|
||||
).not.toBe(normalizedSyntaxFingerprint("function sample(i) { return i++; }"));
|
||||
});
|
||||
|
||||
it("keeps formatting and local renames normalized", () => {
|
||||
expect(
|
||||
normalizedSyntaxFingerprint(
|
||||
"function renamed(value) {\n return value++ ;\n }",
|
||||
),
|
||||
).toBe(normalizedSyntaxFingerprint("function sample(i) { return i++; }"));
|
||||
});
|
||||
Reference in new issue
Block a user