From d4c32c1ff3497cbb1a37d53db162ede20f80f038 Mon Sep 17 00:00:00 2001 From: Bram Reyniers Date: Thu, 23 May 2024 15:56:56 +0200 Subject: [PATCH] create files to use in demo --- presentaties/demo/run | 3 ++ presentaties/demo/submission/correct/main.py | 2 + presentaties/demo/submission/wrong/main.py | 2 + presentaties/demo/test.py | 37 +++++++++++++++++++ presentaties/demo/verslag.docx | 0 presentaties/demo/verslag.pdf | Bin 6 files changed, 44 insertions(+) create mode 100755 presentaties/demo/run create mode 100644 presentaties/demo/submission/correct/main.py create mode 100644 presentaties/demo/submission/wrong/main.py create mode 100644 presentaties/demo/test.py create mode 100644 presentaties/demo/verslag.docx create mode 100644 presentaties/demo/verslag.pdf diff --git a/presentaties/demo/run b/presentaties/demo/run new file mode 100755 index 00000000..7eb088d6 --- /dev/null +++ b/presentaties/demo/run @@ -0,0 +1,3 @@ +#! /usr/bin/env sh + +python test.py diff --git a/presentaties/demo/submission/correct/main.py b/presentaties/demo/submission/correct/main.py new file mode 100644 index 00000000..91403275 --- /dev/null +++ b/presentaties/demo/submission/correct/main.py @@ -0,0 +1,2 @@ +def sum(a, b): + return a + b diff --git a/presentaties/demo/submission/wrong/main.py b/presentaties/demo/submission/wrong/main.py new file mode 100644 index 00000000..5023035e --- /dev/null +++ b/presentaties/demo/submission/wrong/main.py @@ -0,0 +1,2 @@ +def sum(a, b): + return a - b diff --git a/presentaties/demo/test.py b/presentaties/demo/test.py new file mode 100644 index 00000000..8c604d35 --- /dev/null +++ b/presentaties/demo/test.py @@ -0,0 +1,37 @@ +import os +from submission import main + +correct_path = os.environ["CORRECT"] +failed_path = os.environ["FAILED"] +failed_exit_code = int(os.environ["EXIT_TEST_FAILED"]) + +test_cases = [ + (0, 0, 0), + (1, 2, 3), + (3, 4, 7), + (5, 6, 11), + (7, 8, 15), + (9, 10, 19), + (11, 12, 23), + (13, 14, 27), + (15, 16, 31), + (17, 18, 35), + (19, 20, 39) +] + +def run_tests(): + has_failed = False + with open(correct_path, "w") as correct, open(failed_path, "w") as failed: + for test in test_cases: + a, b, expected = test + result = main.sum(a, b) + if result == expected: + correct.write(f"{a} {b} {expected}\n") + else: + failed.write(f"{a} {b} {expected}\n") + has_failed = True + if has_failed: + exit(failed_exit_code) + +if __name__ == "__main__": + run_tests() diff --git a/presentaties/demo/verslag.docx b/presentaties/demo/verslag.docx new file mode 100644 index 00000000..e69de29b diff --git a/presentaties/demo/verslag.pdf b/presentaties/demo/verslag.pdf new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391