[pypy-svn] rev 2085 - in pypy/trunk/src/pypy/translator: . test

sanxiyn at codespeak.net sanxiyn at codespeak.net
Sun Oct 26 19:41:08 CET 2003


Author: sanxiyn
Date: Sun Oct 26 19:41:07 2003
New Revision: 2085

Modified:
   pypy/trunk/src/pypy/translator/gencl.py
   pypy/trunk/src/pypy/translator/test/test_cltrans.py
   pypy/trunk/src/pypy/translator/translator.py
Log:
gencl: one line fix -- op_and_ to logand.
test_cltrans: more PyrexTestCase-originated tests

translator: import snippet as module so that you can
dir() to see what are available. my_bool and my_range's
already in snippet.


Modified: pypy/trunk/src/pypy/translator/gencl.py
==============================================================================
--- pypy/trunk/src/pypy/translator/gencl.py	(original)
+++ pypy/trunk/src/pypy/translator/gencl.py	Sun Oct 26 19:41:07 2003
@@ -38,6 +38,7 @@
         "le": "<=",
         "eq": "=",
         "gt": ">",
+        "and_": "logand",
         "getitem": "elt",
     }
     def op_binary(self, op):

Modified: pypy/trunk/src/pypy/translator/test/test_cltrans.py
==============================================================================
--- pypy/trunk/src/pypy/translator/test/test_cltrans.py	(original)
+++ pypy/trunk/src/pypy/translator/test/test_cltrans.py	Sun Oct 26 19:41:07 2003
@@ -88,10 +88,17 @@
         self.assertEquals(f4(0, 2, 3), 3)
         f5 = make_cl_func(t.int_id)
         self.assertEquals(f5(3), 3)
+        f6 = make_cl_func(t.time_waster)
+        self.assertEquals(f6(30), 3657)
 
     def test_string(self):
         cl_greet = make_cl_func(t.greet, [str])
         self.assertEquals(cl_greet("world"), "helloworld")
 
+    def test_string2(self):
+        cl_stringmaker = make_cl_func(t.nested_whiles)
+        self.assertEquals(cl_stringmaker(111, 114),
+                          "...!...!...!...!...!")
+
 if __name__ == '__main__':
     test.main()

Modified: pypy/trunk/src/pypy/translator/translator.py
==============================================================================
--- pypy/trunk/src/pypy/translator/translator.py	(original)
+++ pypy/trunk/src/pypy/translator/translator.py	Sun Oct 26 19:41:07 2003
@@ -21,11 +21,11 @@
     f = t.compile()                    # pyrex compilation
     assert f(arg) == func(arg)
 
-Some functions will be provided for the benefit of interactive testing.
-Currently there are my_bool and my_range, plus the ones defined in
-test.snippet.
+Some functions are provided for the benefit of interactive testing.
+Try dir(test) for list of current snippets.
 """
 
+
 import autopath
 
 from pypy.objspace.flow.model import *
@@ -111,19 +111,7 @@
 
 
 if __name__ == '__main__':
-    from pypy.translator.test.snippet import *
-
-    def my_bool(x):
-        return not not x
-
-    def my_range(i):
-        lst = []
-        while i > 0:
-            i = i - 1
-            lst.append(i)
-        lst.reverse()
-        return lst
-
+    from pypy.translator.test import snippet as test
     print __doc__
 
     # 2.3 specific -- sanxiyn


More information about the Pypy-commit mailing list