-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New "exception" checker, for expected exceptions.
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
floatsrel, | ||
identical, | ||
linecount, | ||
exception, | ||
linematches, | ||
rstripped, | ||
sorted, | ||
|
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,30 @@ | ||
from re import split as resplit | ||
from typing import Union | ||
|
||
from dmoj.result import CheckerResult | ||
from dmoj.utils.unicode import utf8bytes | ||
|
||
verdict = '\u2717\u2713' | ||
|
||
|
||
def check( | ||
process_output: bytes, judge_output: bytes, point_value: float = 1, exceptionType: str = '', **kwargs | ||
) -> Union[CheckerResult, bool]: | ||
found = kwargs['result'].feedback.split('.')[-1] | ||
passed = (found == exceptionType or len(found) > 0 and len(exceptionType) == 0) | ||
|
||
if kwargs['result'].output != '': | ||
extended_feedback = ('Any type of exception' if exceptionType == '' else 'An exception of type "' + exceptionType) + '" was expected, but none has been raised:\nYour output: ' + kwargs['result'].output | ||
else: | ||
extended_feedback = None if passed else 'An exception was raised, but another exception type was expected:\nRaised: ' + found + '\nExpected: ' + exceptionType | ||
|
||
kwargs['result'].proc_output = '' | ||
kwargs['result'].result_flag = 0 if passed else 1 | ||
|
||
return CheckerResult( | ||
passed=passed, | ||
points=point_value, | ||
extended_feedback=extended_feedback | ||
) | ||
|
||
check.run_on_error = True # type: ignore |