|
| 1 | +from checkpy import * |
| 2 | +from _basics_no_listcomp import * |
| 3 | +from _static_analysis import * |
| 4 | + |
| 5 | +import ast |
| 6 | + |
| 7 | +@t.passed(doctest_ok) |
| 8 | +def has_functions(): |
| 9 | + """alle gevraagde functies zijn aanwezig""" |
| 10 | + assert defines_function("isalpha") |
| 11 | + assert defines_function("islower") |
| 12 | + assert defines_function("isupper") |
| 13 | + assert defines_function("isdigit") |
| 14 | + assert defines_function("isblank") |
| 15 | + assert not has_string("defgh"), "gebruik de variabelen uit de string-module voor deze opdracht" |
| 16 | + assert not has_string("DEFGH"), "gebruik de variabelen uit de string-module voor deze opdracht" |
| 17 | + assert not has_string("1234"), "gebruik de variabelen uit de string-module voor deze opdracht" |
| 18 | + assert has_string(".ascii_lowercase"), "gebruik de variabelen uit de string-module voor deze opdracht" |
| 19 | + assert has_string(".ascii_uppercase"), "gebruik de variabelen uit de string-module voor deze opdracht" |
| 20 | + assert has_string(".whitespace"), "gebruik de variabelen uit de string-module voor deze opdracht" |
| 21 | + |
| 22 | +@t.passed(has_functions) |
| 23 | +def test_isalpha(test): |
| 24 | + """functie `isalpha` werkt correct""" |
| 25 | + assert getFunction("isalpha")('a') == True |
| 26 | + assert getFunction("isalpha")('9') == False |
| 27 | + assert getFunction("isalpha")('e') == True |
| 28 | + assert getFunction("isalpha")('á') == False |
| 29 | + assert getFunction("isalpha")(' ') == False |
| 30 | + |
| 31 | +@t.passed(has_functions) |
| 32 | +def test_islower(test): |
| 33 | + """functie `islower` werkt correct""" |
| 34 | + assert getFunction("islower")('a') == True |
| 35 | + assert getFunction("islower")('9') == False |
| 36 | + assert getFunction("islower")('e') == True |
| 37 | + assert getFunction("islower")('A') == False |
| 38 | + assert getFunction("islower")(' ') == False |
| 39 | + |
| 40 | +@t.passed(has_functions) |
| 41 | +def test_isupper(test): |
| 42 | + """functie `isupper` werkt correct""" |
| 43 | + assert getFunction("isupper")('A') == True |
| 44 | + assert getFunction("isupper")('9') == False |
| 45 | + assert getFunction("isupper")('e') == False |
| 46 | + assert getFunction("isupper")('á') == False |
| 47 | + assert getFunction("isupper")(' ') == False |
| 48 | + |
| 49 | +@t.passed(has_functions) |
| 50 | +def test_isdigit(test): |
| 51 | + """functie `isdigit` werkt correct""" |
| 52 | + assert getFunction("isdigit")('A') == False |
| 53 | + assert getFunction("isdigit")('9') == True |
| 54 | + assert getFunction("isdigit")('e') == False |
| 55 | + assert getFunction("isdigit")('á') == False |
| 56 | + assert getFunction("isdigit")(' ') == False |
| 57 | + |
| 58 | +@t.passed(has_functions) |
| 59 | +def test_isblank(test): |
| 60 | + """functie `isblank` werkt correct""" |
| 61 | + assert getFunction("isblank")('A') == False |
| 62 | + assert getFunction("isblank")('9') == False |
| 63 | + assert getFunction("isblank")('e') == False |
| 64 | + assert getFunction("isblank")('á') == False |
| 65 | + assert getFunction("isblank")(' ') == True |
0 commit comments