Skip to content

Update applyIteratively to use an Arborist object.#45

Open
aliceofhartley wants to merge 1 commit intoHumanSecurity:mainfrom
aliceofhartley:update_apply_iteratively_to_use_arborist
Open

Update applyIteratively to use an Arborist object.#45
aliceofhartley wants to merge 1 commit intoHumanSecurity:mainfrom
aliceofhartley:update_apply_iteratively_to_use_arborist

Conversation

@aliceofhartley
Copy link

@aliceofhartley aliceofhartley commented Feb 18, 2026

Related PR

This PR is part of a set to allow for restringer to avoid recomputing the same flast to improve performance when working on large js files.

❯ npm run test

> flast@2.2.5 test
> node --test

▶ Arborist tests
  ✔ Verify node replacement works as expected (10.686681ms)
  ✔ Verify the root node replacement works as expected (0.780051ms)
  ✔ Verify only the root node is replaced (0.688748ms)
  ✔ Verify node deletion works as expected (1.945738ms)
  ✔ Verify the correct node is targeted for deletion (1.040962ms)
  ✔ Verify a valid script can be used to initialize an arborist instance (0.644567ms)
  ✔ Verify a valid AST array can be used to initialize an arborist instance (0.492435ms)
  ✔ Verify invalid changes are not applied (0.966168ms)
  ✔ Verify comments aren't duplicated when replacing the root node (1.29902ms)
  ﹣ FIX: Verify comments are kept when replacing a node (0.266878ms) # SKIP
✔ Arborist tests (20.159428ms)
▶ Arborist edge case tests
  ✔ Preserves comments when replacing a non-root node (1.031531ms)
  ✔ Deleting the only element in an array leaves parent valid (0.403394ms)
  ✔ Multiple changes in a single pass (replace and delete siblings) (0.666699ms)
  ✔ Deeply nested node replacement (1.029313ms)
  ✔ Multiple comments on a node being deleted (0.633055ms)
  ✔ Marking the same node for deletion and replacement only applies one change (1.143605ms)
  ✔ AST is still valid and mutable after applyChanges (0.50831ms)
✔ Arborist edge case tests (5.644922ms)
▶ Functionality tests
  ✔ Verify the code breakdown generates the expected nodes by checking the properties of the generated ASTNodes (6.891736ms)
  ✔ Verify the expected functions and classes can be imported (0.463523ms)
  ✔ Verify the code breakdown generates the expected nodes by checking the number of nodes for each expected type (1.565985ms)
  ✔ Verify the AST can be parsed and regenerated into the same code (1.562206ms)
  ✔ Verify generateFlatAST's detailed option works as expected (2.047244ms)
  ✔ Verify a script is parsed in "sloppy mode" if strict mode is restricting parsing (0.947516ms)
  ✔ Verify a script is only parsed in its selected sourceType (0.686763ms)
  ✔ Verify generateFlatAST doesn't throw an exception for invalid code (0.72089ms)
✔ Functionality tests (16.04163ms)
▶ Parsing tests
  ✔ Verify the function-expression-name scope is always replaced with its child scope (7.735669ms)
  ✔ Verify declNode references the local declaration correctly (1.469709ms)
  ✔ Verify a function's identifier isn't treated as a reference (0.660365ms)
  ✔ Verify proper handling of class properties (2.141911ms)
  ✔ Verify the type map is generated accurately (1.075976ms)
  ✔ Verify node relations are parsed correctly (1.342509ms)
  ✔ Verify the module scope is ignored (0.749464ms)
  ✔ Verify the lineage is correct (0.791641ms)
  ✔ Verify null childNodes are correctly parsed (0.689075ms)
  ✔ Verify all identifiers are referenced correctly (0.952257ms)
✔ Parsing tests (18.721888ms)
▶ Utils tests: treeModifier
  ✔ Verify treeModifier sets a generic function name (0.511797ms)
  ✔ Verify treeModifier sets the function's name properly (0.129245ms)
✔ Utils tests: treeModifier (1.396335ms)
▶ Utils tests: applyIteratively
  ✔ Verify applyIteratively cannot remove the root node without replacing it (6.043549ms)
  ✔ Verify applyIteratively catches a critical exception (0.737824ms)
  ✔ Verify applyIteratively works as expected (3.216779ms)
✔ Utils tests: applyIteratively (10.171819ms)
▶ Utils tests: logger
  ✔ Verify logger sets the log level to DEBUG properly (0.270181ms)
  ✔ Verify logger sets the log level to NONE properly (0.211943ms)
  ✔ Verify logger sets the log level to LOG properly (0.152098ms)
  ✔ Verify logger sets the log level to ERROR properly (0.134896ms)
  ✔ Verify logger sets the log function properly (0.19916ms)
  ✔ Verify logger throws an error when setting an unknown log level (0.351146ms)
✔ Utils tests: logger (1.579893ms)
ℹ tests 46
ℹ suites 7
ℹ pass 45
ℹ fail 0
ℹ cancelled 0
ℹ skipped 1
ℹ todo 0
ℹ duration_ms 140.162269

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments