Пример #1
0
 def test_replace_box(self):
     h = HeapCache()
     h.setfield(box1, descr1, box2)
     h.setfield(box1, descr2, box3)
     h.setfield(box2, descr3, box3)
     h.replace_box(box1, box4)
     assert h.getfield(box1, descr1) is None
     assert h.getfield(box1, descr2) is None
     assert h.getfield(box4, descr1) is box2
     assert h.getfield(box4, descr2) is box3
     assert h.getfield(box2, descr3) is box3
Пример #2
0
 def test_replace_box(self):
     h = HeapCache()
     h.setfield(box1, descr1, box2)
     h.setfield(box1, descr2, box3)
     h.setfield(box2, descr3, box3)
     h.replace_box(box1, box4)
     assert h.getfield(box1, descr1) is None
     assert h.getfield(box1, descr2) is None
     assert h.getfield(box4, descr1) is box2
     assert h.getfield(box4, descr2) is box3
     assert h.getfield(box2, descr3) is box3
Пример #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
Пример #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
Пример #5
0
    def test_replace_box_twice(self):
        h = HeapCache()
        h.setfield(box1, descr1, box2)
        h.setfield(box1, descr2, box3)
        h.setfield(box2, descr3, box3)
        h.replace_box(box1, box4)
        h.replace_box(box4, box5)
        assert h.getfield(box5, descr1) is box2
        assert h.getfield(box5, descr2) is box3
        assert h.getfield(box2, descr3) is box3
        h.setfield(box5, descr1, box3)
        assert h.getfield(box4, descr1) is box3

        h = HeapCache()
        h.setfield(box1, descr1, box2)
        h.setfield(box1, descr2, box3)
        h.setfield(box2, descr3, box3)
        h.replace_box(box3, box4)
        h.replace_box(box4, box5)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box5
        assert h.getfield(box2, descr3) is box5
Пример #6
0
    def test_replace_box_twice(self):
        h = HeapCache()
        h.setfield(box1, descr1, box2)
        h.setfield(box1, descr2, box3)
        h.setfield(box2, descr3, box3)
        h.replace_box(box1, box4)
        h.replace_box(box4, box5)
        assert h.getfield(box5, descr1) is box2
        assert h.getfield(box5, descr2) is box3
        assert h.getfield(box2, descr3) is box3
        h.setfield(box5, descr1, box3)
        assert h.getfield(box4, descr1) is box3

        h = HeapCache()
        h.setfield(box1, descr1, box2)
        h.setfield(box1, descr2, box3)
        h.setfield(box2, descr3, box3)
        h.replace_box(box3, box4)
        h.replace_box(box4, box5)
        assert h.getfield(box1, descr1) is box2
        assert h.getfield(box1, descr2) is box5
        assert h.getfield(box2, descr3) is box5