Esempio n. 1
0
def test_SAVE():
    expected_output = [["am0", "DDD", "00a", "eee"], 4]
    test_output = assemble.assemble_instr(["SAVE", "$DDD", 1, "$eee", 26])
    assert (test_output == expected_output)
    expected_output = [["am0", "DDD", "AAA", "eee"], 4]
    test_output = assemble.assemble_instr(["SAVE", "$DDD", -757, "$eee", 26])
    assert (test_output == expected_output)
Esempio n. 2
0
def test_SHR():
    for tryte in test_tryte_registers:
        expected_output = [["Km" + test_tryte_registers[tryte], "MMC"], 2]
        test_output = assemble.assemble_instr(["SHR", tryte, "10", 5])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["km" + test_trint_registers[trint], "MMG"], 2]
        test_output = assemble.assemble_instr(["SHR", trint, "6", 5])
        assert (test_output == expected_output)
Esempio n. 3
0
def test_NOT():
    for tryte in test_tryte_registers:
        expected_output = [["KB" + test_tryte_registers[tryte]], 1]
        test_output = assemble.assemble_instr(["NOT", tryte, 7])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["kB" + test_trint_registers[trint]], 1]
        test_output = assemble.assemble_instr(["NOT", trint, 7])
        assert (test_output == expected_output)
Esempio n. 4
0
def test_DSET():
    for tryte in test_tryte_registers:
        expected_output = [["cA" + test_tryte_registers[tryte]], 1]
        test_output = assemble.assemble_instr(["DSET", tryte, 7])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["ca" + test_trint_registers[trint]], 1]
        test_output = assemble.assemble_instr(["DSET", trint, 7])
        assert (test_output == expected_output)
Esempio n. 5
0
def test_WRITE():
    for tryte in test_tryte_registers:
        expected_output = [["aB" + test_tryte_registers[tryte], "DDD"], 2]
        test_output = assemble.assemble_instr(["WRITE", tryte, "$DDD", 5])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["ab" + test_trint_registers[trint], "DDD"], 2]
        test_output = assemble.assemble_instr(["WRITE", trint, "$DDD", 5])
        assert (test_output == expected_output)
    for tfloat in test_float_registers:
        expected_output = [["gM" + test_float_registers[tfloat], "DDD"], 2]
        test_output = assemble.assemble_instr(["WRITE", tfloat, "$DDD", 7])
        assert (test_output == expected_output)
Esempio n. 6
0
def test_READ():
    for tryte in test_tryte_registers:
        expected_output = [["aA" + test_tryte_registers[tryte], "DDD"], 2]
        test_output = assemble.assemble_instr(["READ", "$DDD", tryte, 5])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["aa" + test_trint_registers[trint], "DDD"], 2]
        test_output = assemble.assemble_instr(["READ", "$DDD", trint, 5])
        assert (test_output == expected_output)
    for tfloat in test_float_registers:
        expected_output = [["gm" + test_float_registers[tfloat], "DDD"], 2]
        test_output = assemble.assemble_instr(["READ", "$DDD", tfloat, 7])
        assert (test_output == expected_output)
Esempio n. 7
0
def test_SHOW():
    for tryte in test_tryte_registers:
        expected_output = [["aA" + test_tryte_registers[tryte]], 1]
        test_output = assemble.assemble_instr(["SHOW", tryte, 7])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["aa" + test_trint_registers[trint]], 1]
        test_output = assemble.assemble_instr(["SHOW", trint, 7])
        assert (test_output == expected_output)
    for tfloat in test_float_registers:
        expected_output = [["ga" + test_float_registers[tfloat]], 1]
        test_output = assemble.assemble_instr(["SHOW", tfloat, 7])
        assert (test_output == expected_output)
Esempio n. 8
0
def test_ABS():
    for tryte in test_tryte_registers:
        expected_output = [["KA" + test_tryte_registers[tryte]], 1]
        test_output = assemble.assemble_instr(["ABS", tryte, 7])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["kA" + test_trint_registers[trint]], 1]
        test_output = assemble.assemble_instr(["ABS", trint, 7])
        assert (test_output == expected_output)
    for tfloat in test_float_registers:
        expected_output = [["gD" + test_float_registers[tfloat]], 1]
        test_output = assemble.assemble_instr(["ABS", tfloat, 7])
        assert (test_output == expected_output)
Esempio n. 9
0
def test_FLIP():
    for tryte in test_tryte_registers:
        expected_output = [["Kf" + test_tryte_registers[tryte]], 1]
        test_output = assemble.assemble_instr(["FLIP", tryte, 7])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["kf" + test_trint_registers[trint]], 1]
        test_output = assemble.assemble_instr(["FLIP", trint, 7])
        assert (test_output == expected_output)
    for tfloat in test_float_registers:
        expected_output = [["gd" + test_float_registers[tfloat]], 1]
        test_output = assemble.assemble_instr(["FLIP", tfloat, 7])
        assert (test_output == expected_output)
Esempio n. 10
0
def test_TELL():
    for tryte in test_tryte_registers:
        expected_output = [["aB" + test_tryte_registers[tryte]], 1]
        test_output = assemble.assemble_instr(["TELL", tryte, 7])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["ab" + test_trint_registers[trint]], 1]
        test_output = assemble.assemble_instr(["TELL", trint, 7])
        assert (test_output == expected_output)
    for tfloat in test_float_registers:
        expected_output = [["gA" + test_float_registers[tfloat]], 1]
        test_output = assemble.assemble_instr(["TELL", tfloat, 7])
        assert (test_output == expected_output)
Esempio n. 11
0
def test_POP():
    for tryte in test_tryte_registers:
        expected_output = [["bB" + test_tryte_registers[tryte]], 1]
        test_output = assemble.assemble_instr(["POP", tryte, 7])
        assert (test_output == expected_output)
    for trint in test_trint_registers:
        expected_output = [["bb" + test_trint_registers[trint]], 1]
        test_output = assemble.assemble_instr(["POP", trint, 7])
        assert (test_output == expected_output)
    for tfloat in test_float_registers:
        expected_output = [["gB" + test_float_registers[tfloat]], 1]
        test_output = assemble.assemble_instr(["POP", tfloat, 7])
        assert (test_output == expected_output)
Esempio n. 12
0
def test_SETINT():
    possible_inputs = [str(i) for i in range(27)]
    for i in range(27):
        expected_output = [["0i" + test_septavingt_chars[i], "DDD"], 2]
        test_output = assemble.assemble_instr(
            ["SETINT", "$DDD", possible_inputs[i], 5])
        assert (test_output == expected_output)
Esempio n. 13
0
def test_SET_trint_to_num():
    for trint in test_trint_registers:
        expected_output = [[
            "kb" + test_trint_registers[trint], "000", "0bC", "EGa"
        ], 4]
        test_output = assemble.assemble_instr(["SET", trint, 1000000, 23])
        assert (test_output == expected_output)
Esempio n. 14
0
def test_XOR_trint_with_num():
    for trint in test_trint_registers:
        expected_output = [[
            "kh" + test_trint_registers[trint], "000", "0bC", "EGa"
        ], 4]
        test_output = assemble.assemble_instr(["XOR", trint, 1000000, 23])
        assert (test_output == expected_output)
Esempio n. 15
0
def test_ADD_float_to_num():
    for tfloat in test_float_registers:
        expected_output = [[
            "ge" + test_float_registers[tfloat], "00b", "e00", "000"
        ], 4]
        test_output = assemble.assemble_instr(["ADD", tfloat, 5.0, 23])
        assert (test_output == expected_output)
Esempio n. 16
0
def test_DIV_float_by_num():
    for tfloat in test_float_registers:
        expected_output = [[
            "gg" + test_float_registers[tfloat], "00b", "e00", "000"
        ], 4]
        test_output = assemble.assemble_instr(["DIV", tfloat, 5.0, 23])
        assert (test_output == expected_output)
Esempio n. 17
0
def test_CMP_float_with_num():
    for tfloat in test_float_registers:
        expected_output = [[
            "g0" + test_float_registers[tfloat], "00b", "e00", "000"
        ], 4]
        test_output = assemble.assemble_instr(["CMP", tfloat, 5.0, 23])
        assert (test_output == expected_output)
Esempio n. 18
0
def test_SWAP_trytes():
    for tryte1 in test_tryte_registers:
        for tryte2 in test_tryte_registers:
            expected_output = [[
                "I" + test_tryte_registers[tryte1] +
                test_tryte_registers[tryte2]
            ], 1]
            test_output = assemble.assemble_instr(["SWAP", tryte1, tryte2, 11])
            assert (test_output == expected_output)
Esempio n. 19
0
def test_SWAP_trints():
    for trint1 in test_trint_registers:
        for trint2 in test_trint_registers:
            reg1_pos = test_trint_register_names.find(trint1)
            reg2_pos = test_trint_register_names.find(trint2)
            num = 9 * reg1_pos + reg2_pos
            opcode = handle_instr.signed_value_to_tryte(num + 4 * 81 - 40)
            opcode = "j" + opcode[1:]
            expected_output = [[opcode], 1]
            test_output = assemble.assemble_instr(["SWAP", trint1, trint2, 98])
            assert (test_output == expected_output)
Esempio n. 20
0
def test_DIV_floats():
    for tfloat1 in test_float_registers:
        for tfloat2 in test_float_registers:
            reg1_pos = test_float_register_names.index(tfloat1)
            reg2_pos = test_float_register_names.index(tfloat2)
            num = 9 * reg1_pos + reg2_pos
            opcode = handle_instr.signed_value_to_tryte(num - 0 * 81 - 40)
            opcode = "f" + opcode[1:]
            expected_output = [[opcode], 1]
            test_output = assemble.assemble_instr(
                ["DIV", tfloat1, tfloat2, 289])
            assert (test_output == expected_output)
Esempio n. 21
0
def test_NOOP():
    expected_output = [["00a"], 1]
    test_output = assemble.assemble_instr(['NOOP', 11])
    assert (test_output == expected_output)
Esempio n. 22
0
def test_XOR_tryte_with_num():
    for tryte in test_tryte_registers:
        expected_output = [["Kh" + test_tryte_registers[tryte], "00i"], 2]
        test_output = assemble.assemble_instr(["XOR", tryte, 9, 29])
        assert (test_output == expected_output)
Esempio n. 23
0
def test_HALT():
    expected_output = [["000"], 1]
    test_output = assemble.assemble_instr(['HALT', 11])
    assert (test_output == expected_output)
Esempio n. 24
0
def test_PRINT():
    expected_output = [["c00", "DDD", "MME"], 3]
    test_output = assemble.assemble_instr(["PRINT", "$DDD", "8", 9])
    assert (test_output == expected_output)
Esempio n. 25
0
def test_WAIT():
    expected_output = [["00A"], 1]
    test_output = assemble.assemble_instr(['WAIT', 11])
    assert (test_output == expected_output)
Esempio n. 26
0
def test_SET_tryte_to_num():
    for tryte in test_tryte_registers:
        expected_output = [["Kb" + test_tryte_registers[tryte], "00g"], 2]
        test_output = assemble.assemble_instr(["SET", tryte, 7, 213])
        assert (test_output == expected_output)
Esempio n. 27
0
def test_FILL():
    expected_output = [["af0", "DDD", "0b0", "0CC"], 4]
    test_output = assemble.assemble_instr(["FILL", "$DDD", 54, -84, 26])
    assert (test_output == expected_output)
Esempio n. 28
0
def test_SET_trint_to_addr():
    for trint in test_trint_registers:
        expected_output = [["ac" + test_trint_registers[trint], "DDD"], 2]
        test_output = assemble.assemble_instr(["SET", trint, "$DDD", 37])
        assert (test_output == expected_output)
Esempio n. 29
0
def test_CCMP():
    expected_output = [["0a0"], 1]
    test_output = assemble.assemble_instr(['CCMP', 11])
    assert (test_output == expected_output)
Esempio n. 30
0
def test_SET_float_to_addr():
    for tfloat in test_float_registers:
        expected_output = [["gc" + test_float_registers[tfloat], "DDD"], 2]
        test_output = assemble.assemble_instr(["SET", tfloat, "$DDD", 37])
        assert (test_output == expected_output)