Esempio n. 1
0
def test_install_new_chain():
    class Dead:
        next = None
        def should_remove_jitcell(self):
            return True
    class Alive:
        next = None
        def should_remove_jitcell(self):
            return False
    #
    jc = JitCounter()
    assert jc.lookup_chain(104) is None
    d1 = Dead() 
    jc.install_new_cell(104, d1)
    assert jc.lookup_chain(104) is d1
    d2 = Dead()
    jc.install_new_cell(104, d2)
    assert jc.lookup_chain(104) is d2
    assert d2.next is None
    #
    d3 = Alive()
    jc.install_new_cell(104, d3)
    assert jc.lookup_chain(104) is d3
    assert d3.next is None
    d4 = Alive()
    jc.install_new_cell(104, d4)
    assert jc.lookup_chain(104) is d3
    assert d3.next is d4
    assert d4.next is None
Esempio n. 2
0
def test_install_new_chain():
    class Dead:
        next = None

        def should_remove_jitcell(self):
            return True

    class Alive:
        next = None

        def should_remove_jitcell(self):
            return False

    #
    jc = JitCounter()
    assert jc.lookup_chain(104) is None
    d1 = Dead()
    jc.install_new_cell(104, d1)
    assert jc.lookup_chain(104) is d1
    d2 = Dead()
    jc.install_new_cell(104, d2)
    assert jc.lookup_chain(104) is d2
    assert d2.next is None
    #
    d3 = Alive()
    jc.install_new_cell(104, d3)
    assert jc.lookup_chain(104) is d3
    assert d3.next is None
    d4 = Alive()
    jc.install_new_cell(104, d4)
    assert jc.lookup_chain(104) is d3
    assert d3.next is d4
    assert d4.next is None