Skip to main content

Module rewrite

Module rewrite 

Source
Expand description

GDScript assert rewriter — tree-sitter preprocessing for pytest-style rich diffs.

Rewrites assert(expr) calls into Gdt._rewrite_*(...) calls that carry operand values AND the source-text of the condition to the failure formatter, giving messages like:

FAIL  assert(player.hp == 100)  (test_player.gd:42)
  left:  87
  right: 100

Only single-line assert calls are rewritten; multi-line ones are left unchanged so line counts are never disturbed.

§Tree-sitter structure (verified via dump_assert_tree test)

expression_statement
  call
    identifier "assert"          ← function name
    arguments
      (
      binary_operator            ← condition (may be any expression)
        <left>
        ==                       ← unnamed operator token
        <right>
      [, string]                 ← optional message
      )

Structs§

RewriteOutput

Functions§

rewrite_file
rewrite_source