public interface ResultVerifier extends Consumer<ResultVerifier.SnippetRun>
Modifier and Type | Interface and Description |
---|---|
static class |
ResultVerifier.SnippetRun
Provides the test execution data.
|
Modifier and Type | Method and Description |
---|---|
void |
accept(ResultVerifier.SnippetRun snippetRun)
Performs a verification of a result of a snippet execution.
|
static ResultVerifier |
getDefaultResultVerifier()
Creates a default
ResultVerifier . |
static ResultVerifier |
getIdentityFunctionDefaultResultVerifier()
Creates a default
ResultVerifier for the IdentityFunctionTest . |
void accept(ResultVerifier.SnippetRun snippetRun) throws PolyglotException
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.accept
in interface Consumer<ResultVerifier.SnippetRun>
snippetRun
- the snippet execution data. The ResultVerifier.SnippetRun
provides the actual
snippet parameters, the execution result, or the PolyglotException
thrown
by the execution. If the snippet execution throws an
IllegalArgumentException
, it's converted to PolyglotException
.PolyglotException
- may propagate the PolyglotException
from the snippetRunAssertionError
- may throw an AssertionError
as a result of a verificationstatic ResultVerifier getDefaultResultVerifier()
ResultVerifier
. The default ResultVerifier
tests that the
result type is in bounds specified by the Snippet
.ResultVerifier
static ResultVerifier getIdentityFunctionDefaultResultVerifier()
ResultVerifier
for the IdentityFunctionTest
. The returned
ResultVerifier
tests that the identity function does not change the parameter type.ResultVerifier
for IdentityFunctionTest
.