[pypy-commit] pypy default: add a test_pypy_c for struct unpack from array

bdkearns noreply at buildbot.pypy.org
Sun May 4 22:53:19 CEST 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: 
Changeset: r71268:582d5e465ec2
Date: 2014-05-04 16:51 -0400
http://bitbucket.org/pypy/pypy/changeset/582d5e465ec2/

Log:	add a test_pypy_c for struct unpack from array

diff --git a/pypy/module/pypyjit/test_pypy_c/test_buffers.py b/pypy/module/pypyjit/test_pypy_c/test_buffers.py
--- a/pypy/module/pypyjit/test_pypy_c/test_buffers.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_buffers.py
@@ -25,3 +25,42 @@
             guard_true(i69, descr=...)
             --TICK--
         """)
+
+    def test_struct_unpack(self):
+        def main(n):
+            import struct
+            import array
+            a = array.array('c', struct.pack('i', 42))
+            i = 0
+            while i < n:
+                i += 1
+                struct.unpack('i', a)  # ID: unpack
+            return i
+        log = self.run(main, [1000])
+        assert log.result == 1000
+        loop, = log.loops_by_filename(self.filepath)
+        assert loop.match_by_id('unpack', """
+            guard_not_invalidated(descr=...)
+            i93 = getarrayitem_raw(i55, 0, descr=<ArrayU 1>)
+            i94 = getarrayitem_raw(i55, 1, descr=<ArrayU 1>)
+            i95 = getarrayitem_raw(i55, 2, descr=<ArrayU 1>)
+            i96 = getarrayitem_raw(i55, 3, descr=<ArrayU 1>)
+            i97 = int_lshift(i94, 8)
+            i98 = int_or(i93, i97)
+            i99 = int_lshift(i95, 16)
+            i100 = int_or(i98, i99)
+            i101 = int_ge(i96, 128)
+            guard_false(i101, descr=...)
+            i102 = int_lshift(i96, 24)
+            i103 = int_or(i100, i102)
+            p104 = new(descr=<SizeDescr 24>)
+            p105 = new_array(0, descr=<ArrayP 8>)
+            setfield_gc(p104, p105, descr=<FieldP list.items 16>)
+            call(ConstClass(_ll_list_resize_hint_really_look_inside_iff__listPtr_Signed_Bool), p104, 1, 1, descr=<Callv 0 rii EF=4>)
+            guard_no_exception(descr=...)
+            p106 = getfield_gc(p104, descr=<FieldP list.items 16>)
+            i107 = getfield_raw(50657024, descr=<FieldS pypysig_long_struct.c_value 0>)
+            setfield_gc(p104, 1, descr=<FieldS list.length 8>)
+            i108 = int_lt(i107, 0)
+            guard_false(i108, descr=...)
+        """)


More information about the pypy-commit mailing list