[pypy-svn] r10530 - in pypy/dist/pypy/translator: . java/test

pedronis at codespeak.net pedronis at codespeak.net
Mon Apr 11 15:32:48 CEST 2005


Author: pedronis
Date: Mon Apr 11 15:32:48 2005
New Revision: 10530

Added:
   pypy/dist/pypy/translator/java/test/for_now_dont_test_javatrans.py
      - copied unchanged from r10528, pypy/dist/pypy/translator/java/test/test_javatrans.py
Removed:
   pypy/dist/pypy/translator/java/test/test_javatrans.py
Modified:
   pypy/dist/pypy/translator/gencl.py
Log:
quick fix for gencl

disable translator/java testing (put it to rest for now)



Modified: pypy/dist/pypy/translator/gencl.py
==============================================================================
--- pypy/dist/pypy/translator/gencl.py	(original)
+++ pypy/dist/pypy/translator/gencl.py	Mon Apr 11 15:32:48 2005
@@ -150,7 +150,15 @@
         s = self.str
         result, (seq, start, end) = self.result, self.args
         print "(setq", s(result), "(python-slice", s(seq), s(start), s(end), "))"
-
+    def op_pow(self):
+        s = self.str
+        result, (x,y,z) = self.result, self.args
+        print "(setq", s(result)
+        table = {
+            (int, int, type(None)): (lambda args: args[:2], "(expt %s %s)"),
+        }
+        self.gen.emit_typecase(table, x, y, z)
+        print ")"
 
 class GenCL:
     def __init__(self, fun, input_arg_types=[]):
@@ -314,6 +322,9 @@
         argtypes = tuple(map(self.get_type, args))
         if argtypes in table:
             trans = table[argtypes]
+            if isinstance(trans, tuple): # (manip-args, code-template)
+                manip, trans = trans
+                argreprs = manip(argreprs)                
             print trans % argreprs
         else:
             print "(cond"

Deleted: /pypy/dist/pypy/translator/java/test/test_javatrans.py
==============================================================================
--- /pypy/dist/pypy/translator/java/test/test_javatrans.py	Mon Apr 11 15:32:48 2005
+++ (empty file)
@@ -1,70 +0,0 @@
-import autopath, os
-import py
-from py.process import cmdexec 
-from pypy.tool.udir import udir
-from pypy.translator.java.genjava import GenJava
-from pypy.translator.test import snippet
-from pypy.translator.translator import Translator
-
-
-def setup_module(mod): 
-    try:
-        py.path.local.sysfind('javac')
-    except py.error.ENOENT:
-        py.test.skip("javac not found")
-
-
-class TestNoTypeCGenTestCase:
-
-    objspacename = 'flow'
-
-    def build_jfunc(self, func):
-        try: func = func.im_func
-        except AttributeError: pass
-        t = Translator(func)
-        t.simplify()
-        name = func.func_name
-        self.jdir = udir.mkdir(name)
-        self.gen = GenJava(self.jdir, t)
-
-    def check(self, inputargs, expectedresult):
-        self.gen.gen_test_class(inputargs, expectedresult)
-        cwd = os.getcwd()
-        try:
-            os.chdir(str(self.jdir))
-            cmdexec('javac *.java')
-            assert cmdexec('java test').strip() == 'OK'
-        finally:
-            os.chdir(cwd)
-
-    def test_simple_func(self):
-        self.build_jfunc(snippet.simple_func)
-        self.check([123], 124)
-
-    def test_if_then_else(self):
-        self.build_jfunc(snippet.if_then_else)
-        self.check([2,3,4], 3)
-        self.check([0,3,4], 4)
-        self.check([-1,3,4], 3)
-
-    def test_two_plus_two(self):
-        self.build_jfunc(snippet.two_plus_two)
-        self.check([], 4)
-
-    def test_sieve_of_eratosthenes(self):
-        self.build_jfunc(snippet.sieve_of_eratosthenes)
-        self.check([], 1028)
-
-    def test_string(self):
-        def tstring(name):
-            return len("hello " + name)
-        self.build_jfunc(tstring)
-        self.check(["world"], 11)
-
-    def DONT_test_list_append(self):
-        def tlistappend():
-            l = []
-            l.append(5)
-            return l[0]
-        self.build_jfunc(tlistappend)
-        self.check([], 5)



More information about the Pypy-commit mailing list