Esempio n. 1
0
	def testMethod():
		output = lib.outputOf(
            _fileName,
            stdinArgs = [23],
            overwriteAttributes = [("__name__", "__main__")]
        )
		regex = re.compile(".*"
			"(                      ##)[ ]*(\n)"
			"(                     ###)[ ]*(\n)"
			"(                    ####)[ ]*(\n)"
			"(                   #####)[ ]*(\n)"
			"(                  ######)[ ]*(\n)"
			"(                 #######)[ ]*(\n)"
			"(                ########)[ ]*(\n)"
			"(               #########)[ ]*(\n)"
			"(              ##########)[ ]*(\n)"
			"(             ###########)[ ]*(\n)"
			"(            ############)[ ]*(\n)"
			"(           #############)[ ]*(\n)"
			"(          ##############)[ ]*(\n)"
			"(         ###############)[ ]*(\n)"
			"(        ################)[ ]*(\n)"
			"(       #################)[ ]*(\n)"
			"(      ##################)[ ]*(\n)"
			"(     ###################)[ ]*(\n)"
			"(    ####################)[ ]*(\n)"
			"(   #####################)[ ]*(\n)"
			"(  ######################)[ ]*(\n)"
			"( #######################)[ ]*(\n)"
			"(########################)[ ]*(\n)"
			".*", re.MULTILINE)
		return asserts.match(output, regex)
Esempio n. 2
0
def exactMario23(test):
    test.test = lambda: assertlib.match(
        lib.outputOf(_fileName, stdinArgs=[23]),
        re.compile(
            ".*"
            "(                                            # #)[ ]*(\n)"
            "(                                          # # #)[ ]*(\n)"
            "(                                        # # # #)[ ]*(\n)"
            "(                                      # # # # #)[ ]*(\n)"
            "(                                    # # # # # #)[ ]*(\n)"
            "(                                  # # # # # # #)[ ]*(\n)"
            "(                                # # # # # # # #)[ ]*(\n)"
            "(                              # # # # # # # # #)[ ]*(\n)"
            "(                            # # # # # # # # # #)[ ]*(\n)"
            "(                          # # # # # # # # # # #)[ ]*(\n)"
            "(                        # # # # # # # # # # # #)[ ]*(\n)"
            "(                      # # # # # # # # # # # # #)[ ]*(\n)"
            "(                    # # # # # # # # # # # # # #)[ ]*(\n)"
            "(                  # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(                # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(              # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(            # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(          # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(        # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(      # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(    # # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(  # # # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(# # # # # # # # # # # # # # # # # # # # # # # #)[ ]*"
            ".*", re.MULTILINE))
    test.description = lambda: "print een pyramide van 23 hoog"
Esempio n. 3
0
def exactMario23(test):
    test.test = lambda: assertlib.match(
        lib.outputOf(_fileName, stdinArgs=[23]),
        re.compile(
            ".*"
            "(                                            # #)[ ]*(\n)"
            "(                                          # # #)[ ]*(\n)"
            "(                                        # # # #)[ ]*(\n)"
            "(                                      # # # # #)[ ]*(\n)"
            "(                                    # # # # # #)[ ]*(\n)"
            "(                                  # # # # # # #)[ ]*(\n)"
            "(                                # # # # # # # #)[ ]*(\n)"
            "(                              # # # # # # # # #)[ ]*(\n)"
            "(                            # # # # # # # # # #)[ ]*(\n)"
            "(                          # # # # # # # # # # #)[ ]*(\n)"
            "(                        # # # # # # # # # # # #)[ ]*(\n)"
            "(                      # # # # # # # # # # # # #)[ ]*(\n)"
            "(                    # # # # # # # # # # # # # #)[ ]*(\n)"
            "(                  # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(                # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(              # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(            # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(          # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(        # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(      # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(    # # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(  # # # # # # # # # # # # # # # # # # # # # # #)[ ]*(\n)"
            "(# # # # # # # # # # # # # # # # # # # # # # # #)[ ]*"
            ".*", re.MULTILINE))
    test.description = lambda: "prints a well-formed pyramid of height 23"
Esempio n. 4
0
def handlesWrongInput(test):
    notAllowed = {"the * operator, but instead loops": "*"}
    notAllowedCode(test, lib.source(_fileName), notAllowed)

    test.test = lambda: assertlib.match(
        lib.outputOf(_fileName, stdinArgs=[-100, 24, 1]),
        re.compile(".*(# #)[ ]*(\n)"))
    test.description = lambda: "rejects heights of -100 and 24, then accepts a height of 1"
Esempio n. 5
0
def exactMario3(test):
    test.test = lambda: assertlib.match(
        lib.outputOf(_fileName, stdinArgs=[3]),
        re.compile(
            ".*"
            "(    # #)[ ]*(\n)"
            "(  # # #)[ ]*(\n)"
            "(# # # #)[ ]*"
            ".*", re.MULTILINE))
    test.description = lambda: "correctly prints a pyramid of height 3"
Esempio n. 6
0
    def testMethod():
        output = lib.outputOf(
            _fileName,
            argv = ["fifteen.py", "3"],
            stdinArgs = ["-1"],
            overwriteAttributes = [("__name__", "__main__")],
            ignoreExceptions = [SystemExit]
        )
        regex = re.compile("[\s\S]*"
	      "(08 07 06)[ ]*(\n)"
	      "(05 04 03)[ ]*(\n)"
	      "(02 01 __)[ ]*(\n)"
	      "[\s\S]*", re.MULTILINE)
        return asserts.match(output, regex)
Esempio n. 7
0
def exactMario0(test):
    test.test = lambda: assertlib.match(lib.outputOf(_fileName, stdinArgs=[1]),
                                        re.compile(".*(# #)[ ]*(\n)"))
    test.description = lambda: "prints a well-formed pyramid of height 1"
Esempio n. 8
0
 def testMethod():
     result = lib.getLine(lib.outputOf(_fileName), 0)
     testResult = assertlib.match(result,
                                  ".*9552.*9586.*") or assertlib.match(
                                      result, ".*9586.*9552.*")
     return testResult
Esempio n. 9
0
def handlesWrongInput(test):
    test.test = lambda: assertlib.match(
        lib.outputOf(_fileName, stdinArgs=[-100, 100, 24, 1]),
        re.compile(".*(# #)[ ]*(\n)"))
    test.description = lambda: "Can deal with incorrect input: -100 and 100"
Esempio n. 10
0
def exactMario0(test):
    test.test = lambda: assertlib.match(lib.outputOf(_fileName, stdinArgs=[1]),
                                        re.compile(".*(# #)[ ]*(\n)"))
    test.description = lambda: "print een welgevormde pyramide van 1 hoog"
Esempio n. 11
0
def handlesWrongInput(test):
    test.test = lambda: assertlib.match(
        lib.outputOf(_fileName, stdinArgs=[-100, 100, 24, 1]),
        re.compile(".*(# #)[ ]*(\n)"))
    test.description = lambda: "handelt verkeerde input netjes af"