constant_result=bool_value)
type = self.type
- if type.is_pyobject or type.is_ptr or type.is_float:
+ if type.is_enum or type.is_error:
+ return self
+ elif type.is_pyobject or type.is_int or type.is_ptr or type.is_float:
return CoerceToBooleanNode(self, env)
else:
- if not (type.is_int or type.is_enum or type.is_error):
- error(self.pos,
- "Type '%s' not acceptable as a boolean" % type)
- return self
+ error(self.pos, "Type '%s' not acceptable as a boolean" % type)
def coerce_to_integer(self, env):
# If not already some C integer type, coerce to longint.
False
"""
return x and 1 or False
+
+def test_large_int(unsigned long x):
+ """
+ >>> try: test_large_int(1 << 127)
+ ... except OverflowError: print True
+ True
+ >>> try: test_large_int(1 << 63)
+ ... except OverflowError: print True
+ True
+ >>> try: test_large_int(1 << 48)
+ ... except OverflowError: print True
+ True
+ >>> try: test_large_int(1 << 31)
+ ... except OverflowError: print True
+ True
+ >>> test_large_int(0)
+ False
+ """
+ if True and x:
+ return True
+ else:
+ return False