def test_bool_not(self): function = BoolFunction(examples.bool_not) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1)]) for a in range(2): tmp = BitVec(1, a) result = examples.bool_not(tmp) self.assertEqual(result, not bool(tmp))
def test_bit_xor_2bit(self): function = BoolFunction(examples.bit_xor_2bit) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) ^ BitVec(2, b) self.assertEqual(result, tmp)
def test_bool_not(self): function = BoolFunction(bool_not) assert function._parameters_signature == [(type(BitVec(1)), 1)] for a in range(2): tmp = BitVec(1, a) result = bool_not(tmp) assert result is not bool(tmp)
def test_identity(self): function = BoolFunction(examples.identity) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1)]) result = examples.identity(BitVec(1, '0')) self.assertEqual(result, BitVec(1, '0')) result = examples.identity(BitVec(1, '1')) self.assertEqual(result, BitVec(1, '1'))
def test_identity(self): function = BoolFunction(identity) assert function._parameters_signature == [(type(BitVec(1)), 1)] result = identity(BitVec(1, "0")) assert result == BitVec(1, "0") result = identity(BitVec(1, "1")) assert result == BitVec(1, "1")
def test_identity_2bit(self): function = BoolFunction(identity_2bit) assert function._parameters_signature == [(type(BitVec(2)), 2)] for a in range(4): tmp = BitVec(2, a) result = identity(tmp) assert result == tmp
def test_bit_not_2bit(self): function = BoolFunction(examples.bit_not_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2)]) for a in range(4): tmp = BitVec(2, a) result = examples.bit_not_2bit(tmp) self.assertEqual(result, ~tmp)
def test_bit_not_2bit(self): function = BoolFunction(bit_not_2bit) assert function._parameters_signature == [(type(BitVec(2)), 2)] for a in range(4): tmp = BitVec(2, a) result = bit_not_2bit(tmp) assert result == ~tmp
def test_bool_and(self): function = BoolFunction(bool_and) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) and BitVec(1, b) assert result == tmp
def test_bit_or(self): function = BoolFunction(bit_or) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) | BitVec(1, b) assert result == tmp
def test_bit_xor_2bit(self): function = BoolFunction(bit_xor_2bit) for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) ^ BitVec(2, b) assert result == tmp
def test_bit_or(self): function = BoolFunction(examples.bit_or) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) | BitVec(1, b) self.assertEqual(result, tmp)
def test_bit_or(self): function = BoolFunction(examples.bit_or) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = examples.bit_or(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) | BitVec(1, b) self.assertEqual(result, tmp)
def test_bit_and_2bit(self): function = BoolFunction(examples.bit_and_2bit) self.assertEqual(function._parameters_signature, [(type(BitVec(2)), 2), (type(BitVec(2)), 2)]) for a in range(4): for b in range(4): result = examples.bit_and_2bit(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) & BitVec(2, b) self.assertEqual(result, tmp)
def test_ne(self): function = BoolFunction(examples.ne) self.assertEqual(function._parameters_signature, [(type(BitVec(1)), 1), (type(BitVec(1)), 1)]) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) != BitVec(1, b) self.assertEqual(result, tmp)
def test_bit_xor(self): function = BoolFunction(bit_xor) assert function._parameters_signature == [ (type(BitVec(1)), 1), (type(BitVec(1)), 1), ] for a in range(2): for b in range(2): result = bit_xor(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) ^ BitVec(1, b) assert result == tmp
def test_bit_ne_2bit(self): function = BoolFunction(ne_2bit) assert function._parameters_signature == [ (type(BitVec(2)), 2), (type(BitVec(2)), 2), ] for a in range(4): for b in range(4): result = function.simulate(BitVec(2, a), BitVec(2, b)) tmp = BitVec(2, a) != BitVec(2, b) assert result == tmp
def test_eq(self): function = BoolFunction(eq) assert function._parameters_signature == [ (type(BitVec(1)), 1), (type(BitVec(1)), 1), ] for a in range(2): for b in range(2): result = eq(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) == BitVec(1, b) assert result == tmp
def test_ne(self): function = BoolFunction(ne) assert function._parameters_signature == [ (type(BitVec(1)), 1), (type(BitVec(1)), 1), ] for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) != BitVec(1, b) assert result == tmp
def test_xor(self): function = BoolFunction(bool_and) function = BoolFunction.from_truth_table("0110") assert function.num_inputs() == 2 assert function.num_outputs() == 1 assert function.num_input_bits() == 2 assert function.num_output_bits() == 1 for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) ^ BitVec(1, b) assert result == tmp
def test_not(self): function = BoolFunction(bool_not) function.simulate_all() assert function.num_inputs() == 1 assert function.num_outputs() == 1 assert function.num_input_bits() == 1 assert function.num_output_bits() == 1 assert str(function.truth_table(output_bit=0)) == "01" for a in range(2): tmp = BitVec(1, a) result = function.simulate(tmp) assert result == ~tmp
def test_not(self): function = BoolFunction(examples.bool_not) function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 1) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '01') for a in range(2): tmp = BitVec(1, a) result = function.simulate(tmp) self.assertEqual(result, ~tmp)
def test_xor(self): function = BoolFunction(examples.bool_and) function = BoolFunction.from_truth_table('0110') self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) ^ BitVec(1, b) self.assertEqual(result, tmp)
def test_or(self): function = BoolFunction(bool_or) function.simulate_all() assert function.num_inputs() == 2 assert function.num_outputs() == 1 assert function.num_input_bits() == 2 assert function.num_output_bits() == 1 assert str(function.truth_table(output_bit=0)) == "1110" for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) or BitVec(1, b) assert result == tmp
def test_not_2bit(self): function = BoolFunction(bit_not_2bit) function.simulate_all() assert function.num_inputs() == 1 assert function.num_outputs() == 1 assert function.num_input_bits() == 2 assert function.num_output_bits() == 2 assert str(function.truth_table(output_bit=0)) == "0101" assert str(function.truth_table(output_bit=1)) == "0011" for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp) assert result == ~tmp
def test_identity_2bit(self): function = BoolFunction(identity_2bit) function.simulate_all() assert function.num_inputs() == 1 assert function.num_outputs() == 1 assert function.num_input_bits() == 2 assert function.num_output_bits() == 2 assert str(function.truth_table(output_bit=0)) == "1010" assert str(function.truth_table(output_bit=1)) == "1100" for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp) assert result == tmp
def test_identity(self): function = BoolFunction(identity) function.simulate_all() assert function.num_inputs() == 1 assert function.num_outputs() == 1 assert function.num_input_bits() == 1 assert function.num_output_bits() == 1 assert str(function.truth_table(output_bit=0)) == "10" result = function.simulate(BitVec(1, "0")) assert result == BitVec(1, "0") result = function.simulate(BitVec(1, "1")) assert result == BitVec(1, "1")
def test_identity_2bit(self): function = BoolFunction(examples.identity_2bit) function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 2) self.assertEqual(str(function.truth_table(output_bit=0)), '1010') self.assertEqual(str(function.truth_table(output_bit=1)), '1100') for a in range(4): tmp = BitVec(2, a) result = function.simulate(tmp) self.assertEqual(result, tmp)
def test_or(self): function = BoolFunction(examples.bool_or) function.simulate_all() self.assertEqual(function.num_inputs(), 2) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 2) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '1110') for a in range(2): for b in range(2): result = function.simulate(BitVec(1, a), BitVec(1, b)) tmp = BitVec(1, a) or BitVec(1, b) self.assertEqual(result, tmp)
def test_identity(self): function = BoolFunction(examples.identity) function.simulate_all() self.assertEqual(function.num_inputs(), 1) self.assertEqual(function.num_outputs(), 1) self.assertEqual(function.num_input_bits(), 1) self.assertEqual(function.num_output_bits(), 1) self.assertEqual(str(function.truth_table(output_bit=0)), '10') result = function.simulate(BitVec(1, '0')) self.assertEqual(result, BitVec(1, '0')) result = function.simulate(BitVec(1, '1')) self.assertEqual(result, BitVec(1, '1'))