From 9ecd742de83314c6ff2239c2c380240353e25d13 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Fri, 12 Feb 2010 02:11:55 -0800 Subject: [PATCH] Fix type inference tests for int types. --- Cython/Compiler/TypeInference.py | 2 ++ tests/run/type_inference.pyx | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/TypeInference.py b/Cython/Compiler/TypeInference.py index e4b2f9c2..8c10bcd3 100644 --- a/Cython/Compiler/TypeInference.py +++ b/Cython/Compiler/TypeInference.py @@ -164,6 +164,8 @@ class MarkOverflowingArithmatic(CythonTransform): visit_UnaryMinusNode = visit_dangerous_node + visit_InPlaceAssignmentNode = visit_dangerous_node + visit_Node = visit_safe_node diff --git a/tests/run/type_inference.pyx b/tests/run/type_inference.pyx index 7877f2ce..8ef4e2b4 100644 --- a/tests/run/type_inference.pyx +++ b/tests/run/type_inference.pyx @@ -251,10 +251,29 @@ def safe_only(): """ a = 1.0 assert typeof(a) == "double", typeof(c) - b = 1 - assert typeof(b) == "Python object", typeof(b) + b = 1; + assert typeof(b) == "long", typeof(b) c = MyType() assert typeof(c) == "MyType", typeof(c) + for i in range(10): pass + assert typeof(i) == "long", typeof(i) + d = 1 + res = ~d + assert typeof(d) == "long", typeof(d) + + # potentially overflowing arithmatic + e = 1 + e += 1 + assert typeof(e) == "Python object", typeof(e) + f = 1 + res = f * 10 + assert typeof(f) == "Python object", typeof(f) + g = 1 + res = 10*(~g) + assert typeof(g) == "Python object", typeof(g) + for j in range(10): + res = -j + assert typeof(j) == "Python object", typeof(j) @infer_types(None) def args_tuple_keywords(*args, **kwargs): -- 2.26.2