Skip to content

Commit 92c07dc

Browse files
hermansjeTimSangster
authored andcommitted
Test current HOF behaviour
1 parent 20adb3f commit 92c07dc

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_check_function.py

+19
Original file line numberDiff line numberDiff line change
@@ -520,3 +520,22 @@ def test_function_call_in_comparison(code):
520520
sct = "Ex().check_function('len')"
521521
res = helper.run({"DC_CODE": code, "DC_SOLUTION": code, "DC_SCT": sct})
522522
assert res["correct"]
523+
524+
525+
def test_ho_function():
526+
# TODO: FunctionParser.visit_Call should append something to name to discern HOF calls
527+
# e.g. () if node.func is Func (this should only affect limited exercises)
528+
sct = "Ex().check_function('hof').check_args(0).has_equal_value(override=2)"
529+
530+
code = """
531+
def hof(arg1):
532+
def inner(arg2):
533+
return arg1, arg2
534+
535+
return inner
536+
537+
hof(1)(2)
538+
"""
539+
540+
res = helper.run({"DC_CODE": code, "DC_SOLUTION": code, "DC_SCT": sct})
541+
assert res["correct"]

0 commit comments

Comments
 (0)