From dc968ab05f6688451c919f48d918249ec34eddb5 Mon Sep 17 00:00:00 2001 From: Llewellyn Falco Date: Sun, 14 Apr 2024 20:01:30 +0000 Subject: [PATCH] - t assert transformed types manual type checking in our loosely typed language how: use the wrapper on all the parameters passed to the lambda Co-Authored-By: 4dsherwood <4dsherwood@users.noreply.github.com> Co-Authored-By: Nitsan Avni Co-Authored-By: Susan Fung <38925660+susanfung@users.noreply.github.com> Co-Authored-By: T. E. Green <78671457+Tegsy@users.noreply.github.com> --- tests/test_parse_inputs.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_parse_inputs.py b/tests/test_parse_inputs.py index 95acba11..c2d0acf8 100644 --- a/tests/test_parse_inputs.py +++ b/tests/test_parse_inputs.py @@ -125,8 +125,19 @@ def test_with_3_parameters(): def to_int(s: str, t: type = str): assert type(s) is t return int(s) + + counter = 0 + def to(tin: type, tout: type): + def wrapped(input): + nonlocal counter + counter += 1 + assert type(input) is tin + return tout(input) + return wrapped parse = Parse.doc_string(auto_approve=True) - parse.transform3(str, int, int).verify_all(lambda s, i1, i2: s * (to_int(i1, int) + to_int(i2, int))) - parse.transform3(str, str, str).verify_all(lambda s, i1, i2: s * (to_int(i1,) + to_int(i2))) + parse.transform3( to(str, str), to(str, int), to(str, int)).verify_all(lambda a, b, c: to(str, str)(a) * (to(int, int)(b) + to(int, int)(c))) + + assert counter == 6 +# assert on all the paramaters