Skip to content

Commit

Permalink
Add test_string_to_ast_to_string_loop test (#1233)
Browse files Browse the repository at this point in the history
  • Loading branch information
parker-research authored Feb 4, 2025
1 parent 9bbd5a5 commit e0daf9c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pyslang/tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,21 @@ def test_symbol_inspection():
assert t.isPackedArray
assert t.bitWidth == 32
assert str(t) == "logic[31:0]"


def test_string_to_ast_to_string_loop() -> None:
"""Test that converting a string to a SyntaxTree and back gives the original string."""
input_str = """
module and_gate (
input wire x,
input wire y,
output wire z
);
assign z = x & y;
endmodule
"""

ast = pyslang.SyntaxTree.fromText(input_str)
output_str = str(ast.root)

assert input_str.rstrip() == output_str.rstrip()

0 comments on commit e0daf9c

Please sign in to comment.