File: test_recursive.py

package info (click to toggle)
pypy3 7.3.19%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212,236 kB
  • sloc: python: 2,098,316; ansic: 540,565; sh: 21,462; asm: 14,419; cpp: 4,451; makefile: 4,209; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 12; awk: 4
file content (29 lines) | stat: -rw-r--r-- 1,142 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python

from rpython.jit.backend.llsupport.codemap import unpack_traceback
from rpython.jit.backend.riscv.test.test_basic import JitRISCVMixin
from rpython.jit.metainterp.test.test_recursive import RecursiveTests


class TestRecursive(JitRISCVMixin, RecursiveTests):
    # for the individual tests see
    # ====> ../../../metainterp/test/test_recursive.py

    def check_get_unique_id(self, codemaps):
        assert len(codemaps) == 3
        # we want to create a map of differences, so unpacking the tracebacks
        # byte by byte
        codemaps.sort(lambda a, b: cmp(a[1], b[1]))
        # biggest is the big loop, smallest is the bridge
        def get_ranges(c):
            ranges = []
            prev_traceback = None
            for b in range(c[0], c[0] + c[1]):
                tb = unpack_traceback(b)
                if tb != prev_traceback:
                    ranges.append(tb)
                    prev_traceback = tb
            return ranges
        assert get_ranges(codemaps[2]) == [[4], [4, 2], [4]]
        assert get_ranges(codemaps[1]) == [[2]]
        assert get_ranges(codemaps[0]) == [[2], []]