Top Description Inners Methods
org.graalvm.polyglot.tck

public Interface ResultVerifier

extends Consumer<ResultVerifier.SnippetRun>
Known Direct Implementers
org.graalvm.polyglot.tck.DefaultResultVerifier, org.graalvm.polyglot.tck.IdentityFunctionResultVerifier
Imports
java.util.List, .Objects, java.util.function.Consumer, org.graalvm.polyglot.PolyglotException, .Value

Allows a custom verification of a result of a snippet execution.
Since
0.30

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ResultVerifier.SnippetRun

Provides the test execution data.

Method Summary

Modifier and TypeMethod and Description
public void
accept(ResultVerifier.SnippetRun
the snippet execution data. The 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.
snippetRun
)

Redeclares java.util.function.Consumer.accept.

Performs a verification of a result of a snippet execution.

public static ResultVerifier

Returns:

the default ResultVerifier
getDefaultResultVerifier
()

Creates a default ResultVerifier.

public static ResultVerifier

Returns:

the default ResultVerifier for IdentityFunctionTest.
getIdentityFunctionDefaultResultVerifier
()

Creates a default ResultVerifier for the IdentityFunctionTest.

Inherited from java.util.function.Consumer:
andThen

Method Detail

acceptback to summary
public void accept(ResultVerifier.SnippetRun snippetRun) throws PolyglotException

Redeclares java.util.function.Consumer.accept.

Performs 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
snippetRun:ResultVerifier.SnippetRun

the snippet execution data. The 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.

Annotations
@Override
Exceptions
PolyglotException:
may propagate the PolyglotException from the snippetRun
AssertionError:
may throw an AssertionError as a result of a verification
Since
0.30
getDefaultResultVerifierback to summary
public static 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

Since
19.0
getIdentityFunctionDefaultResultVerifierback to summary
public static 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 ResultVerifier for IdentityFunctionTest.

Since
19.1.0
org.graalvm.polyglot.tck back to summary

public final Class ResultVerifier.SnippetRun

extends Object
Class Inheritance

Provides the test execution data.
Since
0.30

Field Summary

Modifier and TypeField and Description
private final PolyglotException
private final List<? extends Value>
private final Value
private final Snippet

Constructor Summary

AccessConstructor and Description
private
SnippetRun(final Snippet snippet, final List<? extends Value> parameters, Value result, PolyglotException exception)

Method Summary

Modifier and TypeMethod and Description
public static ResultVerifier.SnippetRun

Returns:

the SnippetRun
create
(final Snippet
the executed Snippet
snippet
,
final List<? extends Value>
the actual parameters of snippet execution
parameters
,
final Value
the result of snippet execution
result
)

Creates a new SnippetRun for successful execution.

public static ResultVerifier.SnippetRun

Returns:

the SnippetRun
create
(final Snippet
the executed Snippet
snippet
,
final List<? extends Value>
the actual parameters of snippet execution
parameters
,
final PolyglotException
the PolyglotException thrown during snippet execution
exception
)

Creates a new SnippetRun for failed execution.

public PolyglotException

Returns:

the PolyglotException thrown during the execution or null in case of successful execution.
getException
()

Returns the PolyglotException thrown during snippet execution.

public List<? extends Value>

Returns:

the parameters
getParameters
()

Returns the actual parameters of a snippet execution.

public Value

Returns:

the result of a snippet execution or null in case of execution failure.
getResult
()

Returns the result of a snippet execution.

pack-priv Snippet
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

exceptionback to summary
private final PolyglotException exception
parametersback to summary
private final List<? extends Value> parameters
resultback to summary
private final Value result
snippetback to summary
private final Snippet snippet

Constructor Detail

SnippetRunback to summary
private SnippetRun(final Snippet snippet, final List<? extends Value> parameters, Value result, PolyglotException exception)

Method Detail

createback to summary
public static ResultVerifier.SnippetRun create(final Snippet snippet, final List<? extends Value> parameters, final Value result)

Creates a new SnippetRun for successful execution.

Parameters
snippet:Snippet

the executed Snippet

parameters:List<? extends Value>

the actual parameters of snippet execution

result:Value

the result of snippet execution

Returns:ResultVerifier.SnippetRun

the SnippetRun

Since
0.30
createback to summary
public static ResultVerifier.SnippetRun create(final Snippet snippet, final List<? extends Value> parameters, final PolyglotException exception)

Creates a new SnippetRun for failed execution.

Parameters
snippet:Snippet

the executed Snippet

parameters:List<? extends Value>

the actual parameters of snippet execution

exception:PolyglotException

the PolyglotException thrown during snippet execution

Returns:ResultVerifier.SnippetRun

the SnippetRun

Since
0.30
getExceptionback to summary
public PolyglotException getException()

Returns the PolyglotException thrown during snippet execution. If the snippet execution throws an IllegalArgumentException, this exception is first converted to a PolyglotException, and the resulting PolyglotException is provided by this method.

Returns:PolyglotException

the PolyglotException thrown during the execution or null in case of successful execution.

Since
0.30
getParametersback to summary
public List<? extends Value> getParameters()

Returns the actual parameters of a snippet execution.

Returns:List<? extends Value>

the parameters

Since
0.30
getResultback to summary
public Value getResult()

Returns the result of a snippet execution.

Returns:Value

the result of a snippet execution or null in case of execution failure.

Since
0.30
getSnippetback to summary
pack-priv Snippet getSnippet()