Skip to content
Snippets Groups Projects
Commit df9b0a8e authored by Daniel Bauer's avatar Daniel Bauer :speech_balloon:
Browse files

add integer function printing test

parent 10bc7bac
No related branches found
No related tags found
1 merge request!368Integer functions
...@@ -75,3 +75,27 @@ def test_arithmetic_precedence(): ...@@ -75,3 +75,27 @@ def test_arithmetic_precedence():
expr = (a / b) + (c / (d + e) * f) expr = (a / b) + (c / (d + e) * f)
code = cprint(expr) code = cprint(expr)
assert code == "a / b + c / (d + e) * f" assert code == "a / b + c / (d + e) * f"
def test_printing_integer_functions():
(i, j, k) = [PsExpression.make(PsSymbol(x, UInt(64))) for x in "ijk"]
cprint = CAstPrinter()
from pystencils.backend.ast.expressions import (
PsLeftShift,
PsRightShift,
PsBitwiseAnd,
PsBitwiseOr,
PsBitwiseXor,
PsIntDiv,
)
expr = PsBitwiseAnd(
PsBitwiseXor(
PsBitwiseXor(j, k),
PsBitwiseOr(PsLeftShift(i, PsRightShift(j, k)), PsIntDiv(i, k)),
),
i,
)
code = cprint(expr)
assert code == "(j ^ k ^ (i << (j >> k) | i / k)) & i"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment