From 9380b52917a08f6e78205452a63975db6335de5d Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni Date: Thu, 28 Jul 2022 00:14:33 -0500 Subject: [PATCH] tests PymbolicToASTMapper --- test/test_pymbolic.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_pymbolic.py b/test/test_pymbolic.py index d30dbdbb..774a4c82 100644 --- a/test/test_pymbolic.py +++ b/test/test_pymbolic.py @@ -955,6 +955,18 @@ def test_nodecount(): assert get_num_nodes(expr) == 12 +def test_python_ast_interop_roundtrip(): + from pymbolic.interop.ast import (ASTToPymbolic, + PymbolicToASTMapper) + + ast2p = ASTToPymbolic() + p2ast = PymbolicToASTMapper() + ntests = 40 + for i in range(ntests): + expr = generate_random_expression(seed=(5+i)) + assert ast2p(p2ast(expr)) == expr + + if __name__ == "__main__": import sys if len(sys.argv) > 1: