1# mode: run 2# tag: condexpr 3# ticket: 267 4 5cimport cython 6 7def ident(x): return x 8 9def constants(x): 10 """ 11 >>> constants(4) 12 1 13 >>> constants(5) 14 10 15 """ 16 a = 1 if x < 5 else 10 17 return a 18 19def temps(x): 20 """ 21 >>> temps(4) 22 1 23 >>> temps(5) 24 10 25 """ 26 return ident(1) if ident(x) < ident(5) else ident(10) 27 28 29def nested(x): 30 """ 31 >>> nested(1) 32 1 33 >>> nested(2) 34 2 35 >>> nested(3) 36 3 37 """ 38 a = 1 if x == 1 else (2 if x == 2 else 3) 39 return a 40 41 42@cython.test_fail_if_path_exists('//CondExprNode') 43def const_true(a,b): 44 """ 45 >>> const_true(1,2) 46 1 47 """ 48 return a if 1 == 1 else b 49 50@cython.test_fail_if_path_exists('//CondExprNode') 51def const_false(a,b): 52 """ 53 >>> const_false(1,2) 54 2 55 """ 56 return a if 1 != 1 else b 57