[pypy-svn] r28514 - in pypy/dist/pypy/translator/cli: . test

antocuni at codespeak.net antocuni at codespeak.net
Thu Jun 8 15:04:28 CEST 2006


Author: antocuni
Date: Thu Jun  8 15:04:26 2006
New Revision: 28514

Modified:
   pypy/dist/pypy/translator/cli/class_.py
   pypy/dist/pypy/translator/cli/test/runtest.py
   pypy/dist/pypy/translator/cli/test/test_runtest.py
Log:
bugfix.



Modified: pypy/dist/pypy/translator/cli/class_.py
==============================================================================
--- pypy/dist/pypy/translator/cli/class_.py	(original)
+++ pypy/dist/pypy/translator/cli/class_.py	Thu Jun  8 15:04:26 2006
@@ -83,7 +83,7 @@
     def _toString(self):
         self.ilasm.begin_function('ToString', [], 'string', False, 'virtual', 'instance', 'default')
         self.ilasm.opcode('ldarg.0')
-        self.ilasm.call('string class [pypylib]pypy.test.Result::ToPython(object)')
+        self.ilasm.call('string class [pypylib]pypy.test.Result::InstanceToPython(object)')
         self.ilasm.ret()
         self.ilasm.end_function()
 

Modified: pypy/dist/pypy/translator/cli/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/runtest.py	(original)
+++ pypy/dist/pypy/translator/cli/test/runtest.py	Thu Jun  8 15:04:26 2006
@@ -34,12 +34,13 @@
         assert res1 == res2
 
 def format_object(TYPE, ilasm):
-    if isinstance(TYPE, (ootype.BuiltinType, ootype.Instance)) and TYPE is not ootype.String:
-        ilasm.call_method('string object::ToString()', virtual=True)
-    elif TYPE is ootype.Void:
+    if TYPE is ootype.Void:
         ilasm.opcode('ldstr "None"')
     else:
-        type_ = cts.lltype_to_cts(TYPE)
+        if isinstance(TYPE, (ootype.BuiltinType, ootype.Instance)) and TYPE is not ootype.String:
+            type_ = 'object'
+        else:
+            type_ = cts.lltype_to_cts(TYPE)
         ilasm.call('string class [pypylib]pypy.test.Result::ToPython(%s)' % type_)
 
 
@@ -245,3 +246,6 @@
 
     def is_of_instance_type(self, val):
         return isinstance(val, InstanceWrapper)
+
+    def read_attr(self, obj, name):
+        py.test.skip('read_attr not supported on gencli tests')

Modified: pypy/dist/pypy/translator/cli/test/test_runtest.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_runtest.py	(original)
+++ pypy/dist/pypy/translator/cli/test/test_runtest.py	Thu Jun  8 15:04:26 2006
@@ -46,3 +46,11 @@
         def fn():
             raise IndexError
         self.interpret_raises(LookupError, fn, [])
+
+    def test_object_or_none(self):
+        def fn(flag):
+            if flag:
+                return "hello";
+            else:
+                return None
+        assert self.interpret(fn, [False]) is None



More information about the Pypy-commit mailing list