[pypy-svn] r7612 - pypy/trunk/src/pypy/translator/test
arigo at codespeak.net
arigo at codespeak.net
Tue Nov 23 13:39:32 CET 2004
Author: arigo
Date: Tue Nov 23 13:39:32 2004
New Revision: 7612
Modified:
pypy/trunk/src/pypy/translator/test/snippet.py
pypy/trunk/src/pypy/translator/test/test_ctrans.py
Log:
Three new tests, two of them purposefully failing currently.
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 Tue Nov 23 13:39:32 2004
@@ -63,6 +63,15 @@
array[2] = array[0] + array[1]
return array[2]
+def get_set_del_slice(l=list):
+ del l[:1]
+ del l[-1:]
+ del l[2:4]
+ l[:1] = [3]
+ l[-1:] = [9]
+ l[2:4] = [8,11]
+ return l[:2], l[5:], l[3:5]
+
def sieve_of_eratosthenes():
"""Sieve of Eratosthenes
Modified: pypy/trunk/src/pypy/translator/test/test_ctrans.py
==============================================================================
--- pypy/trunk/src/pypy/translator/test/test_ctrans.py (original)
+++ pypy/trunk/src/pypy/translator/test/test_ctrans.py Tue Nov 23 13:39:32 2004
@@ -163,20 +163,26 @@
self.assertRaises(IndexError, bare_raise, range(0, 30, 10), False)
self.assertEquals(bare_raise(range(0, 30, 10), True), None)
+ def test_get_set_del_slice(self):
+ fn = self.build_cfunc(snippet.get_set_del_slice)
+ l = list('abcdefghij')
+ result = fn(l)
+ self.assertEquals(l, [3, 'c', 8, 11, 'h', 9])
+ self.assertEquals(result, ([3, 'c'], [9], [11, 'h']))
+
class TypedTestCase(testit.IntTestCase):
def getcompiled(self, func):
- t = Translator(func)
- t.simplify()
-## # builds starting-types from func_defs
-## argstypelist = []
-## if func.func_defaults:
-## for spec in func.func_defaults:
-## if isinstance(spec, tuple):
-## spec = spec[0] # use the first type only for the tests
-## argstypelist.append(spec)
-## a = t.annotate(argstypelist)
-## a.simplify()
+ t = Translator(func, simplifying=True)
+ # builds starting-types from func_defs
+ argstypelist = []
+ if func.func_defaults:
+ for spec in func.func_defaults:
+ if isinstance(spec, tuple):
+ spec = spec[0] # use the first type only for the tests
+ argstypelist.append(spec)
+ a = t.annotate(argstypelist)
+ a.simplify()
return t.ccompile()
def test_set_attr(self):
@@ -247,5 +253,12 @@
self.assertEquals(fn(4), 789)
self.assertEquals(fn(5), 101112)
+ def test_get_set_del_slice(self):
+ fn = self.getcompiled(snippet.get_set_del_slice)
+ l = list('abcdefghij')
+ result = fn(l)
+ self.assertEquals(l, [3, 'c', 8, 11, 'h', 9])
+ self.assertEquals(result, ([3, 'c'], [9], [11, 'h']))
+
if __name__ == '__main__':
testit.main()
More information about the Pypy-commit
mailing list