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

test freeze of cast of bare constant and failing type inference

parent d1a9c0ef
No related branches found
No related tags found
1 merge request!411Freeze casts of bare constants to typed PsConstantExprs
......@@ -29,6 +29,7 @@ from pystencils.backend.ast.expressions import (
PsGe,
PsCall,
PsCast,
PsConstantExpr,
)
from pystencils.backend.constants import PsConstant
from pystencils.backend.functions import PsMathFunction, MathFunctions
......@@ -286,3 +287,6 @@ def test_cast_func():
expr = freeze(CastFunc.as_index(z))
assert expr.structurally_equal(PsCast(ctx.index_dtype, z2))
expr = freeze(CastFunc(42, create_type("int16")))
assert expr.structurally_equal(PsConstantExpr(PsConstant(42, create_type("int16"))))
......@@ -14,6 +14,9 @@ from pystencils.backend.ast.structural import (
PsBlock,
)
from pystencils.backend.ast.expressions import (
PsAddressOf,
PsArrayInitList,
PsCast,
PsConstantExpr,
PsSymbolExpr,
PsSubscript,
......@@ -478,3 +481,19 @@ def test_cfunction():
with pytest.raises(TypificationError):
_ = typify(PsCall(threeway, (x, p)))
def test_inference_fails():
ctx = KernelCreationContext()
typify = Typifier(ctx)
x = PsExpression.make(PsConstant(42))
with pytest.raises(TypificationError):
typify(PsEq(x, x))
with pytest.raises(TypificationError):
typify(PsArrayInitList([x]))
with pytest.raises(TypificationError):
typify(PsCast(ctx.default_dtype, x))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment