示例#1
0
def test_not(circuit):
    a, b = inputs("ab")
    truth_table_test(
        [a, b],
        a >> b >> not_gate,
        (((1, 1), (0, 0)), ((1, 0), (0, 1)), ((0, 1), (1, 0)), ((0, 0), (1, 1))),
    )
示例#2
0
def test_bit(circuit):
    input_lines = inputs("is")
    truth_table_test(
        input_lines,
        input_lines >> bit,
        (
            ((1, 1), 1),
            ((0, 1), 0),
            ((0, 0), 0),
            ((1, 0), 0),
            ((0, 0), 0),
            ((0, 1), 0),
            ((1, 1), 1),
            ((1, 0), 1),
            ((0, 0), 1),
            ((1, 0), 1),
            ((1, 1), 1),
            ((1, 0), 1),
            ((0, 1), []),
            ((0, 1), 0),
            ((1, 0), 0),
        ),
    )
示例#3
0
def test_xor(circuit):
    a, b = inputs("ab")
    truth_table_test(
        [a, b], a >> b >> xor_gate, (((1, 1), 0), ((1, 0), 1), ((0, 1), 1), ((0, 0), 0))
    )
示例#4
0
def test_nand(circuit):
    a, b = inputs("ab")
    truth_table_test(
        [a, b], a >> b >> nand, (((1, 1), 0), ((1, 0), 1), ((0, 1), 1), ((0, 0), 1))
    )