[pypy-svn] rev 2116 - in pypy/trunk/src/pypy/translator: test tool

sanxiyn at codespeak.net sanxiyn at codespeak.net
Wed Oct 29 14:12:51 CET 2003


Author: sanxiyn
Date: Wed Oct 29 14:12:50 2003
New Revision: 2116

Modified:
   pypy/trunk/src/pypy/translator/test/snippet.py
   pypy/trunk/src/pypy/translator/test/test_cltrans.py
   pypy/trunk/src/pypy/translator/tool/buildcl.py
Log:
snippet: cosmetic
cltrans: more tests: if_list, yast
buildcl: quote Lisp list


Modified: pypy/trunk/src/pypy/translator/test/snippet.py
==============================================================================
--- pypy/trunk/src/pypy/translator/test/snippet.py	(original)
+++ pypy/trunk/src/pypy/translator/test/snippet.py	Wed Oct 29 14:12:50 2003
@@ -134,11 +134,11 @@
     """Arbitrary test function"""
     i = 0
     x = 1
-    while i<n:
+    while i < n:
         j = 0
-        while j<=i:
+        while j <= i:
             j = j + 1
-            x = x + (i&j)
+            x = x + (i & j)
         i = i + 1
     return x
 

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	Wed Oct 29 14:12:50 2003
@@ -49,6 +49,8 @@
         self.assertEquals(cl_if(False, 50, 100), 100)
         self.assertEquals(cl_if(0, 50, 100), 100)
         self.assertEquals(cl_if(1, 50, 100), 50)
+        self.assertEquals(cl_if([], 50, 100), 100)
+        self.assertEquals(cl_if([[]], 50, 100), 50)
 
     def test_gcd(self):
         cl_gcd = make_cl_func(t.my_gcd, [int, int])
@@ -114,6 +116,19 @@
         self.assertEquals(result.__class__, Literal)
         self.assertEquals(result.val,
                           '#(#() #(0) #(1) #(0 1) #(2) #(0 2) #(1 2) #(0 1 2))')
+    def test_yast(self):
+        cl_sum = make_cl_func(t.yast) # yet another sum test
+        self.assertEquals(cl_sum(range(12)), 66)
+
+
+# TODO
+# poor_man_range
+# - append/reverse. not RPython. delegate?
+# attrs
+# - attribute. need object. symbol-plist?
+# yast
+# - need way to specify that argument is list of int.
+
 
 if __name__ == '__main__':
     test.main()

Modified: pypy/trunk/src/pypy/translator/tool/buildcl.py
==============================================================================
--- pypy/trunk/src/pypy/translator/tool/buildcl.py	(original)
+++ pypy/trunk/src/pypy/translator/tool/buildcl.py	Wed Oct 29 14:12:50 2003
@@ -31,6 +31,8 @@
         content = '(' + content + ')'
         if isinstance(obj, list):
             content = '#' + content
+        elif isinstance(obj, tuple):
+            content = "'" + content # quote Lisp list
         return content
 
 # for test


More information about the Pypy-commit mailing list