def addResolutionError(fsm):
    candidates = [state for state in fsm if len(state["transitions"]) > 0]
    if not candidates:
        raise ValueError("Can not add resolution error to given fsm")
    else:
        errorState = candidates[randint(0, len(candidates) - 1)]
        trans = errorState["transitions"][randint(0, len(errorState["transitions"]) - 1)]

        unresolvableState = randomWord()
        while unresolvableState in [state["name"] for state in fsm]:
            unresolvableState = randomWord()

        trans["newstate"] = unresolvableState

        return fsm
def generateIllegalInput(fsm):

    correctInput, _ = generateCorrectInput(fsm)
    errorPosition = randint(0, len(correctInput) - 1)

    feasibleInputs = []
    for state in fsm:
        feasibleInputs += [transition["input"] for transition in state["transitions"]]

    wrongInput = randomWord()
    while wrongInput in feasibleInputs:
        wrongInput = randomWord()

    correctInput[errorPosition] = wrongInput

    return correctInput
Beispiel #3
0
def addResolutionError(fsm):
    candidates = [state for state in fsm if len(state['transitions']) > 0]
    if not candidates:
        raise ValueError("Can not add resolution error to given fsm")
    else:
        errorState = candidates[randint(0, len(candidates) - 1)]
        trans = errorState['transitions'][randint(
            0,
            len(errorState['transitions']) - 1)]

        unresolvableState = randomWord()
        while unresolvableState in [state['name'] for state in fsm]:
            unresolvableState = randomWord()

        trans['newstate'] = unresolvableState

        return fsm
def generateIllegalInput(fsm):

    correctInput, _ = generateCorrectInput(fsm)
    errorPosition = randint(0, len(correctInput) - 1)

    feasibleInputs = []
    for state in fsm:
        feasibleInputs += [
            transition['input'] for transition in state['transitions']
        ]

    wrongInput = randomWord()
    while wrongInput in feasibleInputs:
        wrongInput = randomWord()

    correctInput[errorPosition] = wrongInput

    return correctInput