[pypy-svn] r76288 - in pypy/branch/interplevel-array/pypy/module/_demo: . test

hakanardo at codespeak.net hakanardo at codespeak.net
Mon Jul 19 22:15:16 CEST 2010


Author: hakanardo
Date: Mon Jul 19 22:15:13 2010
New Revision: 76288

Modified:
   pypy/branch/interplevel-array/pypy/module/_demo/interp_demo.py
   pypy/branch/interplevel-array/pypy/module/_demo/test/test_demo.py
Log:
a few more methods

Modified: pypy/branch/interplevel-array/pypy/module/_demo/interp_demo.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/_demo/interp_demo.py	(original)
+++ pypy/branch/interplevel-array/pypy/module/_demo/interp_demo.py	Mon Jul 19 22:15:13 2010
@@ -11,8 +11,10 @@
         return W_One()
 w_type.unwrap_spec = [ObjSpace, int]
 
-type_typedef = StdTypeDef("tp",
-                          __new__ = w_type)
+#type_repr = SMM('__repr__', 1, 'a docstring')
+tp_pop    = SMM('pop',    2, defaults=(-1,))
+
+type_typedef = StdTypeDef("tp", __new__ = w_type)
 type_typedef.registermethods(globals())
 
 class W_Zero(W_Object):
@@ -35,4 +37,19 @@
 def repr__One(space, w_one):
     return space.wrap("one")
 
+
+def len__Zero(space, w_zero):
+    return space.wrap(7)
+
+def len__One(space, w_zero):
+    return space.wrap(42)
+
+
+def tp_pop__One_ANY(space, w_one, w_count):
+    return w_count
+
+def tp_pop__Zero_ANY(space, w_zero, w_count):
+    return space.wrap(9)
+
+
 register_all(locals(), globals())

Modified: pypy/branch/interplevel-array/pypy/module/_demo/test/test_demo.py
==============================================================================
--- pypy/branch/interplevel-array/pypy/module/_demo/test/test_demo.py	(original)
+++ pypy/branch/interplevel-array/pypy/module/_demo/test/test_demo.py	Mon Jul 19 22:15:13 2010
@@ -9,3 +9,11 @@
         import _demo
         assert repr(_demo.tp(1)) == 'one'
         assert repr(_demo.tp(0)) == 'zero'
+        assert len(_demo.tp(1)) == 42
+
+        o0 = _demo.tp(0)
+        o1 = _demo.tp(1)
+        assert o0.pop(7) == 9
+        assert o1.pop(7) == 7
+        
+        assert type(_demo.tp(1)) is _demo.tp



More information about the Pypy-commit mailing list