Author: Armin Rigo <[email protected]>
Branch: jit-ordereddict
Changeset: r68547:34fbea034534
Date: 2013-12-25 22:13 +0100
http://bitbucket.org/pypy/pypy/changeset/34fbea034534/
Log: Add a test for bytearray in the JIT (not passing)
diff --git a/rpython/jit/metainterp/test/test_bytearray.py
b/rpython/jit/metainterp/test/test_bytearray.py
new file mode 100644
--- /dev/null
+++ b/rpython/jit/metainterp/test/test_bytearray.py
@@ -0,0 +1,47 @@
+import py
+from rpython.jit.metainterp.test.support import LLJitMixin
+from rpython.rlib.jit import JitDriver
+
+
+class TestByteArray(LLJitMixin):
+
+ def test_getitem(self):
+ x = bytearray("foobar")
+ def fn(n):
+ return x[n]
+ res = self.interp_operations(fn, [3])
+ assert res == ord('b')
+
+ def test_len(self):
+ x = bytearray("foobar")
+ def fn(n):
+ return len(x)
+ res = self.interp_operations(fn, [3])
+ assert res == 6
+
+ def test_setitem(self):
+ x = bytearray("foobar")
+ def fn(n):
+ x[n] = 3
+ return x[3] + 1000 * x[4]
+
+ res = self.interp_operations(fn, [3])
+ assert res == 3 + 1000 * ord('a')
+
+ def test_new_bytearray(self):
+ def fn(n, m):
+ x = bytearray(str(n))
+ x[m] = 4
+ return int(str(x))
+
+ res = self.interp_operations(fn, [610978, 3])
+ assert res == 610478
+
+ def test_slice(self):
+ def fn(n):
+ x = bytearray(str(n))
+ x = x[1:5]
+ x[m] = 5
+ return int(str(x))
+ res = self.interp_operations(fn, [610978, 1])
+ assert res == 1597
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit