Esempio n. 1
0
    def test_length_cache(self):
        h = HeapCache()
        h.new_array(box1, lengthbox1)
        assert h.arraylen(box1) is lengthbox1

        assert h.arraylen(box2) is None
        h.arraylen_now_known(box2, lengthbox2)
        assert h.arraylen(box2) is lengthbox2
Esempio n. 2
0
    def test_length_cache(self):
        h = HeapCache()
        h.new_array(box1, lengthbox1)
        assert h.arraylen(box1) is lengthbox1

        assert h.arraylen(box2) is None
        h.arraylen_now_known(box2, lengthbox2)
        assert h.arraylen(box2) is lengthbox2
Esempio n. 3
0
    def test_replace_box_array(self):
        h = HeapCache()
        h.setarrayitem(box1, descr1, index1, box2)
        h.setarrayitem(box1, descr2, index1, box3)
        h.arraylen_now_known(box1, lengthbox1)
        h.setarrayitem(box2, descr1, index2, box1)
        h.setarrayitem(box3, descr2, index2, box1)
        h.setarrayitem(box2, descr3, index2, box3)
        h.replace_box(box1, box4)
        assert h.arraylen(box4) is lengthbox1
        assert h.getarrayitem(box4, descr1, index1) is box2
        assert h.getarrayitem(box4, descr2, index1) is box3
        assert h.getarrayitem(box2, descr1, index2) is box4
        assert h.getarrayitem(box3, descr2, index2) is box4
        assert h.getarrayitem(box2, descr3, index2) is box3

        h.replace_box(lengthbox1, lengthbox2)
        assert h.arraylen(box4) is lengthbox2
Esempio n. 4
0
    def test_replace_box_array(self):
        h = HeapCache()
        h.setarrayitem(box1, descr1, index1, box2)
        h.setarrayitem(box1, descr2, index1, box3)
        h.arraylen_now_known(box1, lengthbox1)
        h.setarrayitem(box2, descr1, index2, box1)
        h.setarrayitem(box3, descr2, index2, box1)
        h.setarrayitem(box2, descr3, index2, box3)
        h.replace_box(box1, box4)
        assert h.arraylen(box4) is lengthbox1
        assert h.getarrayitem(box4, descr1, index1) is box2
        assert h.getarrayitem(box4, descr2, index1) is box3
        assert h.getarrayitem(box2, descr1, index2) is box4
        assert h.getarrayitem(box3, descr2, index2) is box4
        assert h.getarrayitem(box2, descr3, index2) is box3

        h.replace_box(lengthbox1, lengthbox2)
        assert h.arraylen(box4) is lengthbox2