ResultVerifier
public interface ResultVerifier extends Consumer< ResultVerifier.SnippetRun>- Extends
Allows a custom verification of a result of a snippet execution.
Methods3
void accept(ResultVerifier.SnippetRun)
accept
since 0.30void accept(ResultVerifier.SnippetRun snippetRun) throws PolyglotExceptionPerforms a verification of a result of a snippet execution. The custom ResultVerifier overrides the default snippet execution verification. The default verification tests that the result type is in bounds specified by the Snippet. The custom ResultVerifier can be used to do additional checking of a result or an execution exception throwing AssertionError in case of failed assertion. The custom ResultVerifier can hide an expected execution exception. For example the division operator snippet may provide a custom ResultVerifier hiding the execution exception for division by zero. To propagate the execution exception the ResultVerifier should re-throw it. The ResultVerifier can be used to resolve problems in the ErrorTypeTest by making the Snippet's parameter(s) more generic and restrict the required value in the verifier.
Parameters
snippetRunResultVerifier.SnippetRun- the snippet execution data. The
SnippetRunprovides the actual snippet parameters, the execution result, or thePolyglotExceptionthrown by the execution. If the snippet execution throws anIllegalArgumentException, it's converted toPolyglotException.
Throws
PolyglotException- may propagate the
PolyglotExceptionfrom the snippetRun AssertionErrorunchecked- may throw an
AssertionErroras a result of a verification
Overrides accept(T).
static ResultVerifier getDefaultResultVerifier()
getDefaultResultVerifier
staticsince 19.0static ResultVerifier getDefaultResultVerifier()Creates a default ResultVerifier. The default ResultVerifier tests that the result type is in bounds specified by the Snippet.
Returns
ResultVerifier- the default
ResultVerifier
static ResultVerifier getIdentityFunctionDefaultResultVerifier()
getIdentityFunctionDefaultResultVerifier
staticsince 19.1.0static ResultVerifier getIdentityFunctionDefaultResultVerifier()Creates a default ResultVerifier for the IdentityFunctionTest. The returned ResultVerifier tests that the identity function does not change the parameter type.
Returns
ResultVerifier- the default
ResultVerifierforIdentityFunctionTest.
Nested types
public final class .SnippetRunProvides the test execution data.