def testMethod():
		test_potje = assertlib.fileContainsFunctionDefinitions(_fileName, "simuleer_potje_Monopoly")
		test_groot_aantal_potjes = assertlib.fileContainsFunctionDefinitions(_fileName, "simuleer_groot_aantal_potjes_Monopoly")
		info = ""
		if not test_potje:
			info = "de functie simuleer_potje_Monopoly is nog niet gedefinieerd"
		elif not test_groot_aantal_potjes:
			info = "de functie simuleer_potje_Monopoly is gedefinieerd :) \n  - de functie simuleer_groot_aantal_potjes_Monopoly nog niet"
		return test_potje and test_groot_aantal_potjes, info
Ejemplo n.º 2
0
 def testMethod():
     test_game = assertlib.fileContainsFunctionDefinitions(
         _fileName, "simulate_monopoly")
     test_games = assertlib.fileContainsFunctionDefinitions(
         _fileName, "simulate_monopoly_games")
     info = ""
     if not test_game:
         info = "the function simulate_monopoly has not been defined"
     elif not test_games:
         info = "the function simulate_monopoly has been defined :) \n  -the function simulate_monopoly_games has not yet been defined"
     return test_game and test_games, info
Ejemplo n.º 3
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            return False

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            return False

        output = lib.getFunction(function_name, _fileName)(test_text)
        output.sort()

        if "boy's" not in output:
            info = "Make sure to deal in the right way with punctuations."
            return False, info

        if "festive," in output or "season." in output:
            info = "Make sure there are no periods and/or commas left in list."

        return output == correctlist
Ejemplo n.º 4
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            info = "Make sure you use a function named " + function_name + " as you're writing your code."
            return False, info

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            info = "Make sure your function has 1 argument."
            return False, info

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            info = "Make sure you return an list and nothing else."
            return False, info

        if assertlib.exact(
                lib.getFunction(function_name, _fileName)(test_text),
            [test_text]):
            info = "Make sure that all letters are lowercase."
            return False, info

        if not assertlib.exact(
                lib.getFunction(function_name, _fileName)(""), []):
            info = "For an empty text, the list of words should be empty"
            return False, info

        return assertlib.exact(
            lib.getFunction(function_name, _fileName)(""),
            []) and assertlib.exact(
                lib.getFunction(function_name, _fileName)(test_text),
                [test_text.lower()])
Ejemplo n.º 5
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            info = "Make sure you use a function named " + function_name + " as you're writing your code."
            return False, info

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 2:
            info = "Make sure your function has 2 argument."
            return False, info

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text, max_length),
            "abc")
        if not correct_return:
            info = "Make sure you return an string and nothing else."
            return False, info

        outputtext = lib.getFunction(function_name, _fileName)(test_text,
                                                               max_length)

        if "  " in outputtext:
            info = "Make sure there are no double spaces in the reformatted text."
            return False, info
        if " \n" in outputtext:
            info = "Make sure lines don't start with a white space."
            return False, info
        elif "\n " in outputtext:
            info = "Make sure lines don't end with a white space (after the enter)."
            return False, info

        return True
Ejemplo n.º 6
0
def containsRequiredFunctionDefinitions(test):

	notAllowed = {"break": "break"}
	notAllowedCode(test, lib.source(_fileName), notAllowed)

	test.test = lambda : assertlib.fileContainsFunctionDefinitions(_fileName, "tunnel")
	test.description = lambda : "defines the function `tunnel()`"
Ejemplo n.º 7
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            return False

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 2:
            return False

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text, max_length),
            "abc")
        if not correct_return:
            return False

        reformatted_test_text = ""
        test_text_splitup = test_text.split()

        counter = 0
        for word in test_text_splitup:
            if reformatted_test_text == "":
                reformatted_test_text = word
                counter += len(word)
            elif len(word) + counter < max_length:
                reformatted_test_text += " " + word
                counter += len(word) + 1
            else:
                reformatted_test_text += "\n" + word
                counter = len(word)

        outputtext = lib.getFunction(function_name, _fileName)(test_text,
                                                               max_length)
        return outputtext == reformatted_test_text
	def try_run():
		if assertlib.fileContainsFunctionDefinitions(_fileName, "simuleer_groot_aantal_potjes_Monopoly"):
			try:	
				testInput = lib.getFunction("simuleer_groot_aantal_potjes_Monopoly", _fileName)(10000, 1000000, 1000000)
				return True
			except:
				return False
		return False
Ejemplo n.º 9
0
def containsRequiredFunctionDefinitions(test):

    notAllowed = {"break": "break"}
    notAllowedCode(test, lib.source(_fileName), notAllowed)

    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "basejump")
    test.description = lambda: "definieert de functie `basejump()`"
Ejemplo n.º 10
0
def hasthrow_two_dice(test):

    notAllowed = {"break": "break"}
    notAllowedCode(test, lib.source(_fileName), notAllowed)

    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "throw_two_dice")
    test.description = lambda: "defines the function throw_two_dice"
    test.timeout = lambda: 10
Ejemplo n.º 11
0
	def testMethod():
		correctFunction = False

		if assertlib.fileContainsFunctionDefinitions(_fileName, "simulate_monopoly_games"):
			nArguments = len(lib.getFunction("simulate_monopoly_games", _fileName).arguments)

			if nArguments == 3:
				correctFunction = True
		return correctFunction
Ejemplo n.º 12
0
def hasworp_met_twee_dobbelstenen(test):

    notAllowed = {"break": "break"}
    notAllowedCode(test, lib.source(_fileName), notAllowed)

    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "worp_met_twee_dobbelstenen")
    test.description = lambda: "definieert de functie worp_met_twee_dobbelstenen"
    test.timeout = lambda: 60
    def testMethod():
        correctFunction = False

        if assertlib.fileContainsFunctionDefinitions(
                _fileName, "simuleer_groot_aantal_potjes_monopoly"):
            nArguments = len(
                lib.getFunction("simuleer_groot_aantal_potjes_monopoly",
                                _fileName).arguments)

            if nArguments == 3:
                correctFunction = True
        return correctFunction
Ejemplo n.º 14
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(_fileName, function_name)
        if not hasfunction:
            return False
        
        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(lib.getFunction(function_name, _fileName)(test_text), 1)
        if not correct_return:
            return False

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), -1)
Ejemplo n.º 15
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(_fileName, function_name)
        if not hasfunction:
            info = "Make sure you use a function named " + function_name + " as you're writing your code."
            return False, info
        
        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            info = "Make sure your function has 1 argument."
            return False, info

        correct_return = assertlib.sameType(lib.getFunction(function_name, _fileName)(test_text), 1)
        if not correct_return:
            info = "Make sure you return an list and nothing else."
            return False, info

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), 1)
Ejemplo n.º 16
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(_fileName, function_name)
        if not hasfunction:
            return False
        
        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            return False

        if "" in lib.getFunction(function_name, _fileName)(test_text):
            info = "Make sure to deal in the right way with punctuations."
            return False, info

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), ['stick', 'boy', 'noticed', 'that', 'his', 'christmas', 'tree', 'looked', 'healtier', 'than', 'he', 'did'])
Ejemplo n.º 17
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(_fileName, function_name)
        if not hasfunction:
            return False
        
        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            return False

        if "boy's" not in lib.getFunction(function_name, _fileName)(test_text):
            info = "Make sure to deal in the right way with punctuations."
            return False, info

        return assertlib.exact(lib.getFunction(function_name, _fileName)(test_text), ['stick', "boy's", 'festive', 'season'])
Ejemplo n.º 18
0
    def testMethod():
        if assertlib.fileContainsFunctionDefinitions(file_name, function_name):
            fn = lib.getFunction(function_name, file_name)
            provided_args = fn.arguments
            if len(provided_args) == len(expected_args):
                return True, ""
            else:
                if len(expected_args) == 1:
                    m1 = f"Expected a single argument: {fn_string(function_name, expected_args)}"
                else:
                    m1 = f"Expected {len(expected_args)} arguments: {fn_string(function_name, expected_args)}"
                if len(provided_args) == 1:
                    m2 = f"Your function takes a single argument: {fn_string(function_name, provided_args)}"
                else:
                    m2 = f"Your function takes {len(provided_args)} arguments: {fn_string(function_name, provided_args)}"

                return False, f"Incorrect number of arguments:\n\t{m1}\n\t{m2}"
        else:
            return False, "Function not defined"
Ejemplo n.º 19
0
    def testMethod():
        hasfunction = assertlib.fileContainsFunctionDefinitions(
            _fileName, function_name)
        if not hasfunction:
            return False

        nArguments = len(lib.getFunction(function_name, _fileName).arguments)
        if nArguments != 1:
            return False

        correct_return = assertlib.sameType(
            lib.getFunction(function_name, _fileName)(test_text), [])
        if not correct_return:
            return False

        if "" in lib.getFunction(function_name, _fileName)(test_text):
            info = "Make sure to deal in the right way with punctuations."
            return False, info

        output = lib.getFunction(function_name, _fileName)(test_text)
        output.sort()
        return output == correctlist
Ejemplo n.º 20
0
def hasVierkant(test):
	test.test = lambda : assertlib.fileContainsFunctionDefinitions(_fileName, "vierkant")
	test.description = lambda : "definieert de functie vierkant()"
Ejemplo n.º 21
0
def has_levenshtein(test):
    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "levenshtein_distance")
    test.description = lambda: "definieert de functie levenshtein_distance"
def containsCorrectFunction(test):

    test.test = lambda : assertlib.fileContainsFunctionDefinitions(_fileName, "make_move")
    test.description = lambda : "Correct function found in source"
    test.fail = lambda info : "Check if your function has the correct name: make_move"
Ejemplo n.º 23
0
def has_count_exact_matches(test):
    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "count_exact_matches")
    test.description = lambda: "defines the function count_exact_matches"
Ejemplo n.º 24
0
def containsRequiredFunctionDefinitions(test):
    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "fit")
    test.description = lambda: "definieert de functie `fit()`"
def has_fuzzy_matches(test):
    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "fuzzy_matches")
    test.description = lambda: "definieert de functie fuzzy_matches"
Ejemplo n.º 26
0
def hasMontecarlo(test):
    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "montecarlo")
    test.description = lambda: "definieert de functie montecarlo()"
    test.timeout = lambda: 90
def has_split_needle(test):
    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "split_needle")
    test.description = lambda: "definieert de functie split_needle"
Ejemplo n.º 28
0
def hasNulpunten(test):
    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "nulpunten")
    test.description = lambda: "definieert de functie nulpunten()"
Ejemplo n.º 29
0
def hasSomRandomGetallen(test):
    test.test = lambda : assertlib.fileContainsFunctionDefinitions(_fileName, "SomRandomGetallen")
    test.description = lambda : "definieert de functie SomRandomGetallen"
Ejemplo n.º 30
0
def hasworp_met_twee_dobbelstenen(test):
    test.test = lambda: assertlib.fileContainsFunctionDefinitions(
        _fileName, "worp_met_twee_dobbelstenen")
    test.description = lambda: "definieert de functie worp_met_twee_dobbelstenen"
    test.timeout = lambda: 60