[pypy-commit] pypy arm64: (fijal, arigo)

fijal pypy.commits at gmail.com
Mon Feb 4 09:58:18 EST 2019


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: arm64
Changeset: r95793:35474a89bf8d
Date: 2019-02-04 14:57 +0000
http://bitbucket.org/pypy/pypy/changeset/35474a89bf8d/

Log:	(fijal, arigo)

	Use hypothesis

diff --git a/rpython/jit/backend/aarch64/test/test_instr_builder.py b/rpython/jit/backend/aarch64/test/test_instr_builder.py
--- a/rpython/jit/backend/aarch64/test/test_instr_builder.py
+++ b/rpython/jit/backend/aarch64/test/test_instr_builder.py
@@ -1,4 +1,4 @@
-
+from hypothesis import given, settings, strategies as st
 from rpython.jit.backend.aarch64 import registers as r
 from rpython.jit.backend.aarch64 import codebuilder
 from rpython.jit.backend.aarch64.test.gen import assemble
@@ -14,21 +14,23 @@
     def hexdump(self):
         return ''.join(self.buffer)
 
+
 class TestInstrBuilder(object):
-    def setup_method(self, meth):
-        self.cb = CodeBuilder()
 
-    def test_ret(self):
-        self.cb.RET_r(r.x0.value)
-        res = self.cb.hexdump()
-        exp = assemble('RET x0')
+    @settings(max_examples=20)
+    @given(r1=st.sampled_from(r.registers))
+    def test_ret(self, r1):
+        cb = CodeBuilder()
+        cb.RET_r(r1.value)
+        res = cb.hexdump()
+        exp = assemble('RET %r' % r1)
         assert res == exp
-        self.cb = CodeBuilder()
-        self.cb.RET_r(r.x0.value)
-        self.cb.RET_r(r.x5.value)
-        self.cb.RET_r(r.x3.value)
-        assert self.cb.hexdump() == assemble('RET x0\nRET x5\n RET x3')
 
-    def test_call_header(self):
-        self.cb.STP_rr_preindex(r.x29.value, r.x30.value, r.sp.value, -32)
-        assert self.cb.hexdump() == assemble("STP x29, x30, [sp, -32]!")
+    @settings(max_examples=20)
+    @given(r1=st.sampled_from(r.registers),
+           r2=st.sampled_from(r.registers),
+           offset=st.integers(min_value=-64, max_value=63))
+    def test_call_header(self, r1, r2, offset):
+        cb = CodeBuilder()
+        cb.STP_rr_preindex(r1.value, r2.value, r.sp.value, offset * 8)
+        assert cb.hexdump() == assemble("STP %r, %r, [sp, %d]!" % (r1, r2, offset * 8))


More information about the pypy-commit mailing list