wraith/node_modules/@lezer/python/test/test-incremental.js
Vantz Stockwell 2848d79915 feat: Phase 1 complete — Tauri v2 foundation
Rust backend: SQLite (WAL mode, 8 tables), vault encryption
(Argon2id + AES-256-GCM), settings/connections/credentials
services, 19 Tauri command wrappers. 46/46 tests passing.

Vue 3 frontend: unlock/create vault flow, Pinia app store,
Tailwind CSS v4 dark theme with Wraith branding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 15:09:41 -04:00

34 lines
1.1 KiB
JavaScript

import {parser} from "../dist/index.js"
import {fileTests} from "@lezer/generator/dist/test"
import {Tree, TreeFragment} from "@lezer/common"
describe("Incremental parsing", () => {
// See https://github.com/codemirror/codemirror.next/issues/394
it("doesn't reuse statements in the wrong body", () => {
let input = `class StreamWriter:
def __init__(self):
pass
def a():
pass
def b(self):
""" ${"big block comment to fill up the reuse size quota\n ".repeat(150)} """
pass
`
let ast = parser.parse(input)
let at = input.indexOf("pass")
input = input.slice(0, at) + " " + input.slice(at)
let cache = TreeFragment.applyChanges(TreeFragment.addTree(ast), [{fromA: at, toA: at, fromB: at, toB: at + 1}])
let ast2 = parser.parse(input, cache)
if (ast2.toString() != ast.toString()) throw new Error("Malformed tree")
let lastFunc = ast => {
let cur = ast.cursor(ast.length)
while (cur.type.name != "FunctionDefinition") cur.prev()
return cur.tree
}
if (lastFunc(ast) != lastFunc(ast2)) throw new Error("No reuse")
})
})