-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26e1df9
commit 3556723
Showing
20 changed files
with
218 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from typing import Callable | ||
|
||
from gapper import problem, test_case, test_cases | ||
from gapper.core.test_result import TestResult | ||
from gapper.core.unittest_wrapper import TestCaseWrapper | ||
|
||
|
||
def my_adder(a, b) -> int: | ||
return a + b % 10 | ||
|
||
|
||
adder: Callable[[int, int], int] | ||
|
||
|
||
def custom_test(param: TestCaseWrapper, result_proxy: TestResult, solution, submission): | ||
assert solution(*param.test_param.args, my_adder) == submission( | ||
*param.test_param.args, adder | ||
) | ||
assert my_adder(*param.test_param.args) == adder(*param.test_param.args) | ||
|
||
|
||
@test_cases.param_iter(([i, i + 1] for i in range(10)), gap_override_test=custom_test) | ||
@test_case(1, 2, gap_override_test=custom_test) | ||
@problem(context=["adder"], easy_context=True) | ||
def add(a: int, b: int, the_adder) -> int: | ||
return the_adder(a, b) | ||
|
||
|
||
__problem_config__ = { | ||
"is_script": False, | ||
"check_stdout": False, | ||
"mock_input": False, | ||
"captured_context": ["adder"], | ||
"easy_context": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Callable | ||
|
||
from gapper import problem, test_case, test_cases | ||
from gapper.core.test_result import TestResult | ||
from gapper.core.unittest_wrapper import TestCaseWrapper | ||
from gapper.core.utils import CustomTestFn | ||
|
||
|
||
def factory() -> CustomTestFn: | ||
def my_adder(a, b) -> int: | ||
return a + b % 10 | ||
|
||
adder: Callable[[int, int], int] | ||
|
||
def custom_test( | ||
param: TestCaseWrapper, result_proxy: TestResult, solution, submission | ||
): | ||
nonlocal adder | ||
assert solution(*param.test_param.args, my_adder) == submission( | ||
*param.test_param.args, adder | ||
) | ||
assert my_adder(*param.test_param.args) == adder(*param.test_param.args) | ||
|
||
return custom_test | ||
|
||
|
||
@test_cases.param_iter(([i, i + 1] for i in range(10)), gap_override_test=factory()) | ||
@test_case(1, 2, gap_override_test=factory()) | ||
@problem(context=["adder"], easy_context=True) | ||
def add(a: int, b: int, the_adder) -> int: | ||
return the_adder(a, b) | ||
|
||
|
||
__problem_config__ = { | ||
"is_script": False, | ||
"check_stdout": False, | ||
"mock_input": False, | ||
"captured_context": ["adder"], | ||
"easy_context": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.