[pypy-svn] r18362 - in pypy/dist/pypy/rpython/ootype: . test
boria at codespeak.net
boria at codespeak.net
Tue Oct 11 10:15:14 CEST 2005
Author: boria
Date: Tue Oct 11 10:15:14 2005
New Revision: 18362
Modified:
pypy/dist/pypy/rpython/ootype/ootype.py
pypy/dist/pypy/rpython/ootype/test/test_ootype.py
Log:
* Check that default field values are correctly typed in Class.__init__()
Modified: pypy/dist/pypy/rpython/ootype/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootype/ootype.py (original)
+++ pypy/dist/pypy/rpython/ootype/ootype.py Tue Oct 11 10:15:14 2005
@@ -137,6 +137,11 @@
for name, defn in fields.iteritems():
if type(defn) is not tuple:
fields[name] = (defn, defn._defl())
+ else:
+ ootype, default = defn
+
+ if ootype != typeOf(default):
+ raise TypeError("Expected type %r for default" % ootype)
# ____________________________________________________________
Modified: pypy/dist/pypy/rpython/ootype/test/test_ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootype/test/test_ootype.py (original)
+++ pypy/dist/pypy/rpython/ootype/test/test_ootype.py Tue Oct 11 10:15:14 2005
@@ -21,3 +21,5 @@
c = new(C)
assert c.a == 3
+
+ py.test.raises(TypeError, "Class('test', None, {'a': (Signed, 3.0)})")
More information about the Pypy-commit
mailing list