From 3de7d0357b3ef67b2544b45b31a3acaa994f01bb Mon Sep 17 00:00:00 2001 From: Kristian Larsson Date: Thu, 10 Oct 2024 15:57:02 +0200 Subject: [PATCH] Make sure we find test functions Depending on how well specified the test functions are, the type inference might look a little different. I already fixed the compiler but never added tests for it.. until. now. --- test/stdlib_tests/src/test_testing2.act | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/stdlib_tests/src/test_testing2.act diff --git a/test/stdlib_tests/src/test_testing2.act b/test/stdlib_tests/src/test_testing2.act new file mode 100644 index 000000000..c9ea9e08d --- /dev/null +++ b/test/stdlib_tests/src/test_testing2.act @@ -0,0 +1,50 @@ +import logging +import testing + +actor MathTester(): + def add(a, b): + return a + b + + +actor SyncTester(log_handler): + log = logging.Logger(log_handler) + def test(): + m = MathTester() + log.info("SyncTester.test()", None) + testing.assertEqual(m.add(1, 2), 3, "1 + 2 = 3") + +actor AsyncTester(report_result, log_handler): + log = logging.Logger(log_handler) + def test(): + log.info("AsyncTester.test()", None) + report_result(True, None) + +actor EnvTester(report_result, env, log_handler): + log = logging.Logger(log_handler) + def test(): + log.info("EnvTester.test()", None) + report_result(True, None) + +def _test_foo() -> None: + pass + +def _test_syncact(log_handler: logging.Handler) -> None: + s = SyncTester(log_handler) + return s.test() + +# Make sure test discovery works with the proper type signature +def _test_asyncact1(report_result: action(?bool, ?Exception) -> None, log_handler: logging.Handler) -> None: + s = AsyncTester(report_result, log_handler) + s.test() + +def _test_asyncact2(report_result: action(?bool, ?Exception) -> None, log_handler: logging.Handler) -> None: + s = AsyncTester(report_result, log_handler) + s.test() + +def _test_envtest1(report_result: action(?bool, ?Exception) -> None, env: Env, log_handler: logging.Handler) -> None: + s = EnvTester(report_result, env, log_handler) + s.test() + +def _test_envtest2(report_result: action(?bool, ?Exception) -> None, env: Env, log_handler: logging.Handler) -> None: + s = EnvTester(report_result, env, log_handler) + s.test()