[pypy-svn] r5041 - in pypy/trunk/src/pypy/objspace/std: . test
hpk at codespeak.net
hpk at codespeak.net
Thu Jun 10 19:29:13 CEST 2004
Author: hpk
Date: Thu Jun 10 19:29:12 2004
New Revision: 5041
Removed:
pypy/trunk/src/pypy/objspace/std/concretespace.py
Modified:
pypy/trunk/src/pypy/objspace/std/test/test_intobject.py
Log:
- remove obsolete 'concretespace.py' file
- test that shift left/right with 0 returns the first obj
Deleted: /pypy/trunk/src/pypy/objspace/std/concretespace.py
==============================================================================
--- /pypy/trunk/src/pypy/objspace/std/concretespace.py Thu Jun 10 19:29:12 2004
+++ (empty file)
@@ -1,62 +0,0 @@
-# I (mwh) wanted to get some stuff out of objspace.py
-
-# this file is intended to contain implementations of most of the
-# "concrete objects" layer of the Python/C API
-
-# the idea is, roughly, e.g.:
-#
-# PyInt_FromLong -> space.int.from_long(w_int)
-# PyList_GetItem -> space.list.getitem(w_list, i)
-#
-# etc.
-
-# I'm not sure this is a good idea.
-
-class ConcreteSpace(object):
- __slots__ = ['space']
- def __init__(self, space):
- self.space = space
-
-class IntObjSpace(ConcreteSpace):
- __slots__ = []
- def check(self, ob):
- return isinstance(ob, self.space.W_IntObject)
- def check_exact(self, ob):
- return ob.__class__ is self.space.W_IntObject
- def from_string(self, s, base):
- return self.from_long(int(s, base))
- def from_unicode(self, u, base):
- return self.from_long(int(u, base))
- def from_long(self, l):
- return self.space.W_IntObject(l)
- def as_long(self, w_int):
- if self.check(w_int):
- return w_int.intval
- else:
- # XXX argh. should attempt conversion
- raise OperationError(
- self.space.w_TypeError,
- self.space.W_StringObject("an integer is required"))
- def get_max(self):
- import sys
- return self.from_long(sys.maxint)
-
-class FloatObjSpace(ConcreteSpace):
- __slots__ = []
- def check(self, ob):
- return isinstance(ob, self.space.W_FloatObject)
- def check_exact(self, ob):
- return ob.__class__ is self.space.W_FloatObject
- def from_string(self, w_str):
- return self.from_double(float(w_str))
- def from_double(self, d):
- return self.space.W_FloatObject(d)
- def as_double(self, w_float):
- if self.check(w_float):
- return w_float.floatval
- else:
- # XXX argh. should attempt conversion
- raise OperationError(
- self.space.w_TypeError,
- self.space.W_StringObject("a float is required"))
-
Modified: pypy/trunk/src/pypy/objspace/std/test/test_intobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/test/test_intobject.py (original)
+++ pypy/trunk/src/pypy/objspace/std/test/test_intobject.py Thu Jun 10 19:29:12 2004
@@ -312,6 +312,9 @@
self.assertEquals(42, int('42', 10))
self.assertRaises(TypeError, int, 1, 10)
+ def test_shift_zeros(self):
+ assert (1 << 0) == 1
+ assert (1 >> 0) == 1
if __name__ == '__main__':
testit.main()
More information about the Pypy-commit
mailing list