[pypy-svn] r77606 - in pypy/branch/jitffi/pypy/annotation: . test

antocuni at codespeak.net antocuni at codespeak.net
Tue Oct 5 15:36:57 CEST 2010


Author: antocuni
Date: Tue Oct  5 15:36:55 2010
New Revision: 77606

Modified:
   pypy/branch/jitffi/pypy/annotation/model.py
   pypy/branch/jitffi/pypy/annotation/test/test_model.py
Log:
add a failing test and fix it.  The problem was that annotation_to_lltype
tries to see if the annotation is contained in one of those inside
annotation_to_ll_map, but for SomeSingleFloat whose .const!=None the
.contains() raises TypeError when trying to compare the two consts.  Moving it
as the first solves the problem.



Modified: pypy/branch/jitffi/pypy/annotation/model.py
==============================================================================
--- pypy/branch/jitffi/pypy/annotation/model.py	(original)
+++ pypy/branch/jitffi/pypy/annotation/model.py	Tue Oct  5 15:36:55 2010
@@ -574,11 +574,11 @@
         
 NUMBER = object()
 annotation_to_ll_map = [
+    (SomeSingleFloat(), lltype.SingleFloat),
     (s_None, lltype.Void),   # also matches SomeImpossibleValue()
     (s_Bool, lltype.Bool),
     (SomeInteger(knowntype=r_ulonglong), NUMBER),    
     (SomeFloat(), lltype.Float),
-    (SomeSingleFloat(), lltype.SingleFloat),
     (SomeChar(), lltype.Char),
     (SomeUnicodeCodePoint(), lltype.UniChar),
     (SomeAddress(), llmemory.Address),

Modified: pypy/branch/jitffi/pypy/annotation/test/test_model.py
==============================================================================
--- pypy/branch/jitffi/pypy/annotation/test/test_model.py	(original)
+++ pypy/branch/jitffi/pypy/annotation/test/test_model.py	Tue Oct  5 15:36:55 2010
@@ -128,7 +128,7 @@
     assert isinstance(s_p, SomeOOInstance) and s_p.ootype == C
 
 def test_annotation_to_lltype():
-    from pypy.rlib.rarithmetic import r_uint
+    from pypy.rlib.rarithmetic import r_uint, r_singlefloat
     s_i = SomeInteger()
     s_pos = SomeInteger(nonneg=True)
     s_1 = SomeInteger(nonneg=True); s_1.const = 1
@@ -151,6 +151,9 @@
     C = ootype.Instance('C', ROOT, {})
     ref = SomeOOInstance(C)
     assert annotation_to_lltype(ref) == C
+    s_singlefloat = SomeSingleFloat()
+    s_singlefloat.const = r_singlefloat(0.0)
+    assert annotation_to_lltype(s_singlefloat) == lltype.SingleFloat
     
 def test_ll_union():
     PS1 = lltype.Ptr(lltype.GcStruct('s'))



More information about the Pypy-commit mailing list