Interface ResultVerifier

All Superinterfaces:
Consumer<ResultVerifier.SnippetRun>

public interface ResultVerifier extends Consumer<ResultVerifier.SnippetRun>
Allows a custom verification of a result of a snippet execution.
Since:
0.30
  • Method Details

    • accept

      void accept(ResultVerifier.SnippetRun snippetRun) throws org.graalvm.polyglot.PolyglotException
      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.
      Specified by:
      accept in interface Consumer<ResultVerifier.SnippetRun>
      Parameters:
      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.
      Throws:
      org.graalvm.polyglot.PolyglotException - may propagate the PolyglotException from the snippetRun
      AssertionError - may throw an AssertionError as a result of a verification
      Since:
      0.30
    • getDefaultResultVerifier

      static ResultVerifier getDefaultResultVerifier()
      Creates a default ResultVerifier. The default ResultVerifier tests that the result type is in bounds specified by the Snippet.
      Returns:
      the default ResultVerifier
      Since:
      19.0
    • getIdentityFunctionDefaultResultVerifier

      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:
      the default ResultVerifier for IdentityFunctionTest.
      Since:
      19.1.0