Skip to main content

Module rewrite

Module rewrite 

Source
Expand description

GDScript assert rewriter: preprocessing for pytest-style rich diffs.

Rewrites assert(expr) statements 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 asserts are rewritten; multi-line ones are left unchanged so line counts are never disturbed.

In gdsyntax’s tree an assert is an ASSERT_STMT: the assert keyword and an ARG_LIST holding the condition and an optional message. The replaced range runs from the keyword to the closing parenthesis.

Structs§

RewriteOutput

Functions§

rewrite_file
rewrite_source