Exemplo n.º 1
0
def test_get_value():
    solver = Solver()
    with pytest.raises(ValueError):
        solver.get_value("x")
    solver.inputs = {"x": ["123"], "y": "x AND 119".split()}
    with pytest.raises(KeyError):
        solver.get_value("x")
    solver.outputs = {"x": 123, "y": 115}
    assert solver.get_value("y") == 115
    assert solver.get_value("115") == 115
Exemplo n.º 2
0
def test_do_instruction():
    solver = Solver()
    solver.inputs = {"x": "123", "y": "456"}
    solver.outputs = {"x": 123, "y": 456}

    assert solver.do_instruction(["123"]) == 123
    assert solver.do_instruction(["456"]) == 456
    assert solver.do_instruction("123 AND 456".split()) == 123 & 456
    assert solver.do_instruction("NOT 123".split()) == ~np.uint16(123)
    assert solver.do_instruction(["x"]) == 123
    assert solver.do_instruction(["y"]) == 456
    assert solver.do_instruction("x AND y".split()) == 123 & 456
    assert solver.do_instruction("123 AND y".split()) == 123 & 456
    assert solver.do_instruction("x AND 456".split()) == 123 & 456
    assert solver.do_instruction("NOT x".split()) == ~np.uint16(123)