File: test_resumecode.py

package info (click to toggle)
pypy 5.6.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 97,040 kB
  • ctags: 185,069
  • sloc: python: 1,147,862; ansic: 49,642; cpp: 5,245; asm: 5,169; makefile: 529; sh: 481; xml: 232; lisp: 45
file content (29 lines) | stat: -rw-r--r-- 844 bytes parent folder | download
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

from rpython.jit.metainterp.resumecode import NUMBERING, NULL_NUMBER
from rpython.jit.metainterp.resumecode import create_numbering,\
    unpack_numbering
from rpython.rtyper.lltypesystem import lltype

from hypothesis import strategies, given


def test_pack_unpack():
    examples = [
        [1, 2, 3, 4, 257, 10000, 13, 15],
        [1, 2, 3, 4],
        range(1, 10, 2),
        [13000, 12000, 10000, 256, 255, 254, 257, -3, -1000]
    ]
    for l in examples:
        n = create_numbering(l)
        assert unpack_numbering(n) == l

@given(strategies.lists(strategies.integers(-2**15, 2**15-1)))
def test_roundtrip(l):
    n = create_numbering(l)
    assert unpack_numbering(n) == l

@given(strategies.lists(strategies.integers(-2**15, 2**15-1)))
def test_compressing(l):
    n = create_numbering(l)
    assert len(n.code) <= len(l) * 3