<commit_before>from BinPy.Gates.gates import *
from nose.tools import with_setup, nottest


def AND_test():
    lgate = AND(1, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [0, 0, 1, 0]:
        assert False


def OR_test():
    lgate = OR(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [0, 1, 1, 1]:
        assert False


def NAND_test():
    lgate = NAND(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [1, 1, 0, 1]:
        assert False


def NOR_test():
    lgate = NOR(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [1, 0, 0, 0]:
        assert False


def XOR_test():
    lgate = XOR(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [0, 1, 0, 1]:
        assert False


def XNOR_test():
    lgate = XNOR(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [1, 0, 1, 0]:
        assert False<commit_msg>Tests added for logic gates<commit_after>from BinPy.Gates.gates import *
from nose.tools import with_setup, nottest


def AND_test():
    lgate = AND(1, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [0, 0, 1, 0]:
        assert False

    lgate = AND(1, 0)
    try:
    	lgate.addInput(1)
    	if lgate.output() is not 0:
    		assert False

    	lgate.removeInput(1)
    	if lgate.output() is not 1:
    		assert False
    except Exception, e:
    	assert False

def OR_test():
    lgate = OR(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [0, 1, 1, 1]:
        assert False

    lgate = OR(1, 0)
    try:
    	lgate.addInput(1)
    	if lgate.output() is not 1:
    		assert False

    	lgate.removeInput(1)
    	if lgate.output() is not 1:
    		assert False
    except Exception, e:
    	assert False

def NAND_test():
    lgate = NAND(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [1, 1, 0, 1]:
        assert False

    lgate = NAND(1, 1)
    try:
    	lgate.addInput(1)
    	if lgate.output() is not 0:
    		assert False

    	lgate.removeInput(1)
    	if lgate.output() is not 0:
    		assert False
    except Exception, e:
    	assert False

def NOR_test():
    lgate = NOR(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [1, 0, 0, 0]:
        assert False

    lgate = NOR(1, 0)
    try:
    	lgate.addInput(1)
    	if lgate.output() is not 0:
    		assert False

    	lgate.removeInput(1)
    	if lgate.output() is not 0:
    		assert False
    except Exception, e:
    	assert False

def XOR_test():
    lgate = XOR(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [0, 1, 0, 1]:
        assert False

    lgate = XOR(1, 0)
    try:
    	lgate.addInput(1)
    	if lgate.output() is not 0:
    		assert False

    	lgate.removeInput(1)
    	if lgate.output() is not 0:
    		assert False
    except Exception, e:
    	assert False

def XNOR_test():
    lgate = XNOR(0, 0)
    outputLogic = []

    inputLogic = [(0, 0), (1, 0), (1, 1), (0, 1)]

    for logic in inputLogic:
        lgate.setInputs(logic[0], logic[1])
        outputLogic.append(lgate.output())
    if outputLogic != [1, 0, 1, 0]:
        assert False

        lgate = XNOR(1, 0)
    try:
    	lgate.addInput(1)
    	if lgate.output() is not 1:
    		assert False

    	lgate.removeInput(1)
    	if lgate.output() is not 0:
    		assert False
    except Exception, e:
    	assert False
{'fraction_non_alphanumeric': 0.15001989653800238, 'fraction_numerical': 0.04536410664544369, 'mean_word_length': 2.2558290155440415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2235307', 'n_tokens_mistral': 2103, 'n_tokens_neox': 1923, 'n_words': 529}