[pypy-svn] rev 481 - in pypy/trunk/src/pypy/objspace/std: . test
mwh at codespeak.net
mwh at codespeak.net
Mon May 26 19:35:38 CEST 2003
Author: mwh
Date: Mon May 26 19:35:38 2003
New Revision: 481
Added:
pypy/trunk/src/pypy/objspace/std/test/test_objspace.py
Modified:
pypy/trunk/src/pypy/objspace/std/objspace.py
Log:
add StdObjSpace.newstring and add test_objspace while we're at it
Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py (original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py Mon May 26 19:35:38 2003
@@ -96,6 +96,11 @@
import moduleobject
return moduleobject.W_ModuleObject(self, w_name)
+ def newstring(self, chars_w):
+ chars = [chr(self.unwrap(w_c)) for w_c in chars_w]
+ import stringobject
+ return stringobject.W_StringObject(''.join(chars))
+
# special multimethods
unwrap = MultiMethod('unwrap', 1) # returns an unwrapped object
is_true = MultiMethod('nonzero', 1) # returns an unwrapped bool
Added: pypy/trunk/src/pypy/objspace/std/test/test_objspace.py
==============================================================================
--- (empty file)
+++ pypy/trunk/src/pypy/objspace/std/test/test_objspace.py Mon May 26 19:35:38 2003
@@ -0,0 +1,23 @@
+import unittest, sys
+import testsupport
+from pypy.interpreter import unittest_w
+from pypy.objspace.std import noneobject as nobj
+from pypy.objspace.std.objspace import *
+
+
+class TestStdObjectSpace(unittest_w.TestCase_w):
+
+ def setUp(self):
+ self.space = StdObjSpace()
+
+ def tearDown(self):
+ pass
+
+ def test_newstring(self):
+ w = self.space.wrap
+ s = 'abc'
+ chars_w = [w(ord(c)) for c in s]
+ self.assertEqual_w(w(s), self.space.newstring(chars_w))
+
+if __name__ == '__main__':
+ unittest.main()
More information about the Pypy-commit
mailing list