[pypy-svn] r30042 - pypy/dist/pypy/translator/cli/test
antocuni at codespeak.net
antocuni at codespeak.net
Fri Jul 14 16:47:23 CEST 2006
Author: antocuni
Date: Fri Jul 14 16:47:19 2006
New Revision: 30042
Modified:
pypy/dist/pypy/translator/cli/test/runtest.py
pypy/dist/pypy/translator/cli/test/test_runtest.py
Log:
Don't print the result of the entry_point function when there is only
one argument of type List(String), which is used as 'argv'.
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 Fri Jul 14 16:47:19 2006
@@ -57,17 +57,22 @@
return 'main'
def render(self, ilasm):
- ilasm.begin_function('main', [('string[]', 'argv')], 'void', True, 'static')
-
- if self.wrap_exceptions:
- ilasm.begin_try()
-
try:
ARG0 = self.graph.getargs()[0].concretetype
except IndexError:
ARG0 = None
+ # special case: List(String) == argv
if isinstance(ARG0, ootype.List) and ARG0._ITEMTYPE is ootype.String:
- # special case: List(String) == argv
+ main_argv = True
+ else:
+ main_argv = False
+
+ ilasm.begin_function('main', [('string[]', 'argv')], 'void', True, 'static')
+
+ if self.wrap_exceptions:
+ ilasm.begin_try()
+
+ if main_argv:
ilasm.opcode('ldarg.0')
ilasm.new('instance void class [pypylib]pypy.runtime.List`1<string>::.ctor(!0[])')
else:
@@ -82,10 +87,14 @@
# call the function and convert the result to a string containing a valid python expression
ilasm.call(cts.graph_to_signature(self.graph))
- TYPE = self.graph.getreturnvar().concretetype
- format_object(TYPE, ilasm)
- ilasm.call('void class [mscorlib]System.Console::WriteLine(string)')
- ilasm.leave('return')
+
+ if main_argv:
+ ilasm.opcode('pop') # XXX: return this value
+ else:
+ TYPE = self.graph.getreturnvar().concretetype
+ format_object(TYPE, ilasm)
+ ilasm.call('void class [mscorlib]System.Console::WriteLine(string)')
+ ilasm.leave('return')
if self.wrap_exceptions:
ilasm.end_try()
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 Fri Jul 14 16:47:19 2006
@@ -55,10 +55,3 @@
else:
return None
assert self.interpret(fn, [False]) is None
-
- def test_list_of_string(self):
- def fn(argv):
- return ' '.join(argv)
- res = self.interpret(fn, ['hello', 'world'], annotation=[s_list_of_strings])
- assert self.ll_to_string(res) == 'hello world'
-
More information about the Pypy-commit
mailing list