Commits

Antonio Cuni committed f11fa89

one more test

Comments (0)

Files changed (1)

pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py

         log = self.run(main, [500], threshold=400)
         assert log.result == 500
         loop, = log.loops_by_id('call')
-        loop.match_by_id('call', opcode='CALL_FUNCTION', expected_src="""
+        assert loop.match_by_id('call', opcode='CALL_FUNCTION', expected_src="""
             # make sure that the "block" is not allocated
             ...
             i20 = force_token()
             p32 = call_may_force(11376960, p18, p22, descr=<GcPtrCallDescr>)
             ...
         """)
+
+    def test_import_in_function(self):
+        def main(n):
+            i = 0
+            while i < n:
+                from sys import version  # ID: import
+                i += 1
+            return i
+        #
+        log = self.run(main, [500], threshold=400)
+        assert log.result == 500
+        loop, = log.loops_by_id('import')
+        assert loop.match_by_id('import', """
+            p14 = call(ConstClass(ll_split_chr__GcStruct_listLlT_rpy_stringPtr_Char), p8, 46, descr=<GcPtrCallDescr>)
+            guard_no_exception(descr=<Guard4>)
+            guard_nonnull(p14, descr=<Guard5>)
+            i15 = getfield_gc(p14, descr=<SignedFieldDescr list.length .*>)
+            i16 = int_is_true(i15)
+            guard_true(i16, descr=<Guard6>)
+            p18 = call(ConstClass(ll_pop_default__dum_nocheckConst_listPtr), p14, descr=<GcPtrCallDescr>)
+            guard_no_exception(descr=<Guard7>)
+            i19 = getfield_gc(p14, descr=<SignedFieldDescr list.length .*>)
+            i20 = int_is_true(i19)
+            guard_false(i20, descr=<Guard8>)
+        """)