Carl Friedrich Bolz avatar Carl Friedrich Bolz committed 611610f Draft

floats

Comments (0)

Files changed (2)

 class RPyInt(int):
     __metaclass__ = RPytPrimitiveType
 
+class RPyFloat(float):
+    __metaclass__ = RPytPrimitiveType
+
 class RPythonClass(RPyType):
     def __new__(cls, name, bases, dct):
         result = type.__new__(cls, name, bases, dct)
         return obj
     if obj is int:
         return RPyInt
+    if obj is float:
+        return RPyFloat
+    assert 0, "unknown type %s" % obj
 def test_class():
     class Test(r.RPyObject):
         x = r.attribute(int)
+        y = r.attribute(float)
 
     t = Test()
-    assert t.x == 0
+    assert t.x == t.y == 0
+    assert type(t.x) is int
+    assert type(t.y) is float
     t.x = 5
     assert t.x == 5
     py.test.raises(r.RPythonTypeError, "t.x = 1.0")
     py.test.raises(r.RPythonTypeError, "t.x = 'abc'")
+    t.y = 5.6
+    assert t.y == 5.6
+    py.test.raises(r.RPythonTypeError, "t.y = 1")
+    py.test.raises(r.RPythonTypeError, "t.y = 'abc'")
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.