[pypy-svn] r27086 - in pypy/dist/pypy/annotation: . test
pedronis at codespeak.net
pedronis at codespeak.net
Thu May 11 17:46:43 CEST 2006
Author: pedronis
Date: Thu May 11 17:46:41 2006
New Revision: 27086
Modified:
pypy/dist/pypy/annotation/binaryop.py
pypy/dist/pypy/annotation/test/test_annrpython.py
Log:
unbreak rshift annotation
Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py (original)
+++ pypy/dist/pypy/annotation/binaryop.py Thu May 11 17:46:41 2006
@@ -254,10 +254,12 @@
def lshift((int1, int2)):
return SomeInteger(knowntype=int1.knowntype)
- lshift.can_only_throw = [ValueError]
- rshift = lshift
lshift_ovf = _clone(lshift, [ValueError, OverflowError])
+ def rshift((int1, int2)):
+ return SomeInteger(nonneg=int1.nonneg, knowntype=int1.knowntype)
+ rshift.can_only_throw = [ValueError]
+
def pow((int1, int2), obj3):
knowntype = rarithmetic.compute_restype(int1.knowntype, int2.knowntype)
return SomeInteger(nonneg = int1.nonneg,
@@ -301,9 +303,11 @@
return SomeInteger()
lshift.can_only_throw = [ValueError]
- rshift = lshift
lshift_ovf = _clone(lshift, [ValueError, OverflowError])
+ def rshift((int1, int2)):
+ return SomeInteger(nonneg=True)
+ rshift.can_only_throw = [ValueError]
class __extend__(pairtype(SomeBool, SomeBool)):
Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py (original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py Thu May 11 17:46:41 2006
@@ -2161,7 +2161,15 @@
assert isinstance(s, annmodel.SomeInteger)
assert s.knowntype == inttype
assert s.unsigned == (inttype(-1) > 0)
-
+
+ def test_annotate_rshift(self):
+ def f(x):
+ return x >> 2
+ a = self.RPythonAnnotator()
+ s = a.build_types(f, [annmodel.SomeInteger(nonneg=True)])
+ assert isinstance(s, annmodel.SomeInteger)
+ assert s.nonneg
+
def g(n):
More information about the Pypy-commit
mailing list