def correctInitials1(test): test.test = lambda: assertlib.exact( lib.getFunction("initials", _fileName) ("Johann Friedrich Miescher").upper(), "JFM") test.description = lambda: "initials() returns the correct initials for \"Johann Friedrich Miescher\""
def correctVierkant(test): test.test = lambda: assertlib.between( lib.getFunction("vierkant", _fileName)(), 0.51, 0.54) test.description = lambda: "vierkant geeft de goede afstand terug"
def exact_matches_a(test): test.test = lambda: set( lib.getFunction("exact_matches", _fileName) ("atgacatgcacaagtatgcat", "atgc")) == set([5, 15]) test.description = lambda: "exact_matches works for input 'atgacatgcacaagtatgcat', 'atgc'"
def correctFunc3(test): test.test = lambda : assertlib.between(lib.getFunction("riemann", _fileName)(lambda x : math.sin(x**2), 0, math.pi, 10000), 0.77, 0.78) test.description = lambda : "riemann werkt correct voor een functie die onder de x-as komt"
def correct(test): test.test = lambda: assertlib.exact( sorted( int(p * 10) for p in lib.getFunction("roots", _fileName) (1, 2, -10)), [-43, 23]) test.description = lambda: "roots() yields the two correct roots for a=1, b=2, c=-10"
def correctFunc2(test): test.test = lambda: assertlib.between( lib.getFunction("riemann", _fileName)(lambda x: math.tan( math.cos(math.sin(x))), 0.2, 2.2, 10000), 1.70, 1.71) test.description = lambda: "riemann() yields the correct value when an interval does not start at x=0"
def correctFunc1(test): test.test = lambda : assertlib.between(lib.getFunction("riemann", _fileName)(lambda x : x**(x + 0.5), 0, 1, 10000), 0.52, 0.53) test.description = lambda : "riemann werkt correct voor een simpele functie"
def correctFunc3(test): test.test = lambda: assertlib.between( lib.getFunction("montecarlo", _fileName) (lambda x: math.sin(x**2), 0, -1, math.pi, 1), 0.75, 0.79) test.description = lambda: "montecarlo() yields the correct value when a function goes below the x-axis"
def correctDice(test): test.test = lambda: assertlib.between( lib.getFunction("worp_met_twee_dobbelstenen", _fileName)(), 2, 12) test.description = lambda: "returnt een correcte waarde voor een worp van twee dobbelstenen" test.timeout = lambda: 60
def correctFunc1(test): test.test = lambda: assertlib.between( lib.getFunction("montecarlo", _fileName) (lambda x: x**(x + 0.5), 0, 0, 1, 1), 0.51, 0.54) test.description = lambda: "montecarlo() yields the correct value of an integral on [0,1] for the square function"
def correctFunc2(test): test.test = lambda: assertlib.between( lib.getFunction("montecarlo", _fileName)(lambda x: math.tan( math.cos(math.sin(x))), 0.2, 0, 2.2, 1.5), 1.69, 1.73) test.description = lambda: "montecarlo() yields the correct value when an interval does not start at x=0"
def almostWrongInput(test): test.test = lambda: assertlib.exact( lib.getFunction("initials", _fileName) ("John Double Spaces").upper(), "JDS") test.description = lambda: "initials() returns the correct initials for \"John Double Spaces\""
def correctInitials3(test): test.test = lambda: assertlib.exact( lib.getFunction("initials", _fileName)("Martha Chase").upper(), "MC") test.description = lambda: "initials() returns the correct initials for \"Martha Chase\""
def correctInitials2(test): test.test = lambda: assertlib.exact( lib.getFunction("initials", _fileName)("Phoebus Levene").upper(), "PL") test.description = lambda: "initials() returns the correct initials for \"Phoebus Levene\""
def testMethod(): import monopoly possession = lib.getFunction("possession", _fileName) return asserts.containsOnly( possession(monopoly.Board()).values(), [False])
def try_run(): try: return lib.getFunction("simuleer_groot_aantal_potjes_Monopoly", _fileName)(1500) except: return False
def correctFunc1(test): test.test = lambda: assertlib.between( lib.getFunction("riemann", _fileName) (lambda x: x**(x + 0.5), 0, 1, 10000), 0.52, 0.53) test.description = lambda: "riemann() yields the correct value of an integral on [0,1] for the square function"
def returnTypeIsList(test): test.test = lambda : assertlib.sameType(lib.getFunction("nulpunten", _fileName)(1,2,-10), []) test.description = lambda : "nulpunten geeft een lijst terug"
def correctFunc3(test): test.test = lambda: assertlib.between( lib.getFunction("riemann", _fileName) (lambda x: math.sin(x**2), 0, math.pi, 10000), 0.77, 0.78) test.description = lambda: "riemann() yields the correct value when a function goes below the x-axis"
def correct(test): test.test = lambda : assertlib.exact(sorted(int(p * 10) for p in lib.getFunction("nulpunten", _fileName)(1,2,-10)), [-43, 23]) test.description = lambda : "vindt de nulpunten voor invoer a=1, b=2, c=-10"
def correctFunc2(test): test.test = lambda : assertlib.between(lib.getFunction("riemann", _fileName)(lambda x : math.tan(math.cos(math.sin(x))), 0.2, 2.2, 10000), 1.70, 1.71) test.description = lambda : "riemann werkt correct wanneer het beginpunt niet gelijk is aan 0"
def correctNone(test): test.test = lambda : assertlib.exact(sorted(int(p * 10) for p in lib.getFunction("nulpunten", _fileName)(3,6,9)), []) test.description = lambda : "vindt geen nulpunten voor invoer a=3, b=6, c=9"
def returnTypeIsList(test): test.test = lambda: assertlib.sameType( lib.getFunction("roots", _fileName)(1, 2, -10), []) test.description = lambda: "roots() returns a list"
def testMethod(): throw = lib.getFunction("throw", _fileName) return asserts.containsOnly([throw() for i in range(10000)], list(range(2, 13)))
def correctNone(test): test.test = lambda: assertlib.exact( sorted( int(p * 10) for p in lib.getFunction("roots", _fileName)(3, 6, 9)), []) test.description = lambda: "roots() yields no roots for a=3, b=6, c=9"
def testMethod(): import monopoly possession = lib.getFunction("possession", _fileName) return asserts.sameType(possession(monopoly.Board()), dict())
def is_list_exact_matches(test): test.test = lambda: assertlib.sameType( lib.getFunction("exact_matches", _fileName)("a", "a"), []) test.description = lambda: "exact_matches returns a list"
def testMethod(): throw = lib.getFunction("throw", _fileName) n = 10000 s = sum(throw() for i in range(n)) return asserts.between(s / n, 6.5, 7.5)
def exact_matches_c(test): test.test = lambda: set( lib.getFunction("exact_matches", _fileName) ("atgacatgca", "b")) == set([]) test.description = lambda: "exact_matches works for input 'atgacatgca', 'b'"
def correctVierkant(test): test.test = lambda : assertlib.between(lib.getFunction("square", _fileName)(10000), 0.51, 0.54) test.description = lambda : "square() yields the correct distance"