Exemple #1
0
def test_post_decrement_a():
    warrior = Warrior(processes=[0])
    core = Core(data=[MOV('I', '}', 1, '$', 1), DAT('F', '$', 0, '$', 0)])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert core[1].a_value() == 0
    assert core[1].b_value() == 0
Exemple #2
0
def test_sub_typical():
    warrior = Warrior(processes=[0])
    core = Core(
        data=[SUB('AB', '#', '3', '$', '1'),
              DAT('F', '$', 1, '$', -5)])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert game.core()[1].b_value() == -8
Exemple #3
0
def test_sub_x():
    warrior = Warrior(processes=[0])
    core = Core(data=[SUB('X', '#', '3', '$', '1'), DAT('F', '$', 2, '$', -5)])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    instruction = game.core()[1]
    assert instruction.a_value() == 1
    assert instruction.b_value() == -8
Exemple #4
0
def test_mod_zero():
    warrior = Warrior(processes=[0])
    core = Core(data=[
        MOD('I', '$', 1, '$', 2),
        DAT('F', '$', 0, '$', 0),
        DAT('F', '$', 0, '$', 0)
    ])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert len(warrior.processes()) == 0
Exemple #5
0
def test_seq_i_no():
    warrior = Warrior(processes=[0])
    core = Core(data=[
        SEQ('I', '$', 1, '$', 2),
        JMP('F', '$', 2, '$', 4),
        DAT('F', '$', 2, '$', 4)
    ])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert warrior.processes()[0] == 1
Exemple #6
0
def test_djn_f_not_zero():
    warrior = Warrior(processes=[0])
    core = Core(data=[
        DJN('B', '$', 2, '$', 0),
        DAT('F', '$', 0, '$', 1),
        DAT('F', '$', 0, '$', 1)
    ])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert warrior.processes() == [2]
Exemple #7
0
def test_spl_typical():
    warrior = Warrior(processes=[0])
    core = Core(data=[
        SPL('F', '$', 2, '$', 2),
        DAT('F', '$', 0, '$', 0),
        DAT('F', '$', 0, '$', 0)
    ])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert warrior.processes() == [1, 2]
Exemple #8
0
def test_core_add_cycle_begin_two_times():
    warrior = Warrior(processes=[1])
    core = Core(data=[
        DAT('F', '$', 1, '$', 5),
        ADD('AB', '#', '3', '$', '-5'),
        DAT('F', '$', 1, '$', -5)
    ])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert game.core()[2].b_value() == -2
Exemple #9
0
def test_jmp_typical():
    warrior = Warrior(processes=[2])
    core = Core(data=[
        DAT('F', '$', 1, '$', -5),
        DAT('F', '$', 1, '$', -5),
        JMP('B', '$', -1, '$', 0)
    ])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert game.warriors()[0].processes()[0] == 1
Exemple #10
0
def test_mov_x():
    warrior = Warrior(processes=[0])
    core = Core(data=[
        MOV('X', '$', '1', '$', '2'),
        DAT('F', '$', 1, '$', 7),
        DAT('F', '$', 0, '$', 0)
    ])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert game.core()[2].a_value() == 7
    assert game.core()[2].b_value() == 1
Exemple #11
0
def test_core_postincrement_b():
    warrior = Warrior(processes=[0])
    core = Core(data=[DAT('F', '>', 1, '$', 1), DAT('F', '$', 0, '$', 0)])
    game = Round(core=core, warriors=[warrior], init_warriors=False)
    game.simulation_step()
    assert game.core()[1].b_value() == 1