[pypy-svn] r46930 - in pypy/dist/pypy/annotation: . test

arigo at codespeak.net arigo at codespeak.net
Thu Sep 27 11:14:09 CEST 2007


Author: arigo
Date: Thu Sep 27 11:14:09 2007
New Revision: 46930

Modified:
   pypy/dist/pypy/annotation/binaryop.py
   pypy/dist/pypy/annotation/test/test_annrpython.py
Log:
Annotation test and fix.


Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py	(original)
+++ pypy/dist/pypy/annotation/binaryop.py	Thu Sep 27 11:14:09 2007
@@ -13,7 +13,7 @@
 from pypy.annotation.model import SomePBC, SomeSlice, SomeFloat, s_None
 from pypy.annotation.model import SomeExternalObject, SomeWeakRef
 from pypy.annotation.model import SomeAddress, SomeTypedAddressAccess
-from pypy.annotation.model import SomeCTypesObject
+from pypy.annotation.model import SomeCTypesObject, SomeSingleFloat
 from pypy.annotation.model import unionof, UnionError, set, missing_operation, TLS
 from pypy.annotation.model import read_can_only_throw
 from pypy.annotation.model import add_knowntypedata, merge_knowntypedata
@@ -448,6 +448,12 @@
     inplace_truediv = truediv
 
 
+class __extend__(pairtype(SomeSingleFloat, SomeSingleFloat)):
+    
+    def union((flt1, flt2)):
+        return SomeSingleFloat()
+
+
 class __extend__(pairtype(SomeList, SomeList)):
 
     def union((lst1, lst2)):

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 Sep 27 11:14:09 2007
@@ -14,6 +14,7 @@
 from pypy.annotation.dictdef import DictDef
 from pypy.objspace.flow.model import *
 from pypy.rlib.rarithmetic import r_uint, base_int, r_longlong, r_ulonglong
+from pypy.rlib.rarithmetic import r_singlefloat
 from pypy.rlib import objectmodel
 from pypy.objspace.flow import FlowObjSpace
 
@@ -2848,6 +2849,17 @@
         a = self.RPythonAnnotator()
         a.build_types(f, [int, int])
 
+    def test_r_singlefloat(self):
+        z = r_singlefloat(0.4)
+        def g(n):
+            if n > 0:
+                return r_singlefloat(n * 0.1)
+            else:
+                return z
+        a = self.RPythonAnnotator()
+        s = a.build_types(g, [int])
+        assert isinstance(s, annmodel.SomeSingleFloat)
+
 
 def g(n):
     return [0,1,2,n]



More information about the Pypy-commit mailing list