Commits

Greg Price  committed f48ed5f

Support floats in signatures

  • Participants
  • Parent commits 2fcd49f
  • Branches signatures

Comments (0)

Files changed (2)

File pypy/annotation/types.py

 from pypy.annotation.listdef import ListDef
 
 
+def float():
+    return model.SomeFloat()
+
+def singlefloat():
+    return model.SomeSingleFloat()
+
+def longfloat():
+    return model.SomeLongFloat()
+
+
 def int():
     return model.SomeInteger()
 
+
 def str():
     return model.SomeString()
 
 def char():
     return model.SomeChar()
 
+
 def list(element):
     listdef = ListDef(None, element, mutated=True, resized=True)
     return model.SomeList(listdef)
     listdef = ListDef(None, element, mutated=True, resized=False)
     return model.SomeList(listdef)
 
+
 def instance(class_):
     return lambda bookkeeper: model.SomeInstance(bookkeeper.getuniqueclassdef(class_))

File pypy/rlib/test/test_signature.py

     def str_to_int(s):
         return s
 
+
+def test_signature_float():
+    @signature(types.longfloat(), types.singlefloat(), returns=types.float())
+    def f(a, b):
+        return 3.0
+    assert getsig(f) == [model.SomeLongFloat(), model.SomeSingleFloat(), model.SomeFloat()]
+
+
 def test_signature_list():
     @signature(types.list(types.int()), returns=types.int())
     def f(a):
         l.append(2)
     check_annotator_fails(try_append)
 
+
 def test_signature_instance():
     class C1(object):
         pass