Class ProgramTester


  • public final class ProgramTester
    extends java.lang.Object
    Test a protelis program.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void runExpectingErrors​(java.lang.String program, java.lang.Class<? extends java.lang.Throwable> expectedExceptionType, boolean searchCause, java.lang.String... messageContents)
      Tests a program expecting an error, and checks its message contents.
      static void runExpectingErrors​(java.lang.String program, java.lang.Class<? extends java.lang.Throwable> expectedExceptionType, java.lang.String... messageContents)
      Tests a program expecting an error, and checks its message contents.
      static <E extends java.lang.Throwable>
      void
      runExpectingErrors​(java.lang.String program, java.lang.Class<E> expectedExceptionType, java8.util.function.Consumer<E> analyzer)
      Tests a program expecting an error, and checks its message contents.
      static void runFile​(java.lang.String file)  
      static void runFile​(java.lang.String file, int runs)  
      static void runFile​(java.lang.String file, int runs, java.lang.Object expectedResult)  
      static void runFileWithExplicitResult​(java.lang.String file, java.lang.Object expectedResult)  
      static void runFileWithMultipleRuns​(java.lang.String file)  
      static void runFileWithMultipleRuns​(java.lang.String file, int min, int max)  
      static void runFileWithMultipleRuns​(java.lang.String file, java8.util.stream.IntStream stream)  
      static java.lang.Object runProgram​(java.lang.String s, int runs)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • runFileWithExplicitResult

        public static void runFileWithExplicitResult​(java.lang.String file,
                                                     java.lang.Object expectedResult)
        Parameters:
        file - file to be tested
        expectedResult - result
      • runFile

        public static void runFile​(java.lang.String file)
        Parameters:
        file - file to be tested
      • runExpectingErrors

        public static void runExpectingErrors​(java.lang.String program,
                                              java.lang.Class<? extends java.lang.Throwable> expectedExceptionType,
                                              boolean searchCause,
                                              java.lang.String... messageContents)
        Tests a program expecting an error, and checks its message contents.
        Parameters:
        program - the program to execute. It it ends in ".pt", it will be loaded as Protelis script from classpath
        expectedExceptionType - the type of exception to be thrown
        searchCause - if true, the message contents are searched for in the cause exception message
        messageContents - the strings that the exception message must include
      • runExpectingErrors

        public static <E extends java.lang.Throwable> void runExpectingErrors​(java.lang.String program,
                                                                              java.lang.Class<E> expectedExceptionType,
                                                                              java8.util.function.Consumer<E> analyzer)
        Tests a program expecting an error, and checks its message contents.
        Type Parameters:
        E - exception type (static)
        Parameters:
        program - the program to execute. It it ends in ".pt", it will be loaded as Protelis script from classpath
        expectedExceptionType - the type of exception to be thrown
        analyzer - the actions to perform on the exception
      • runExpectingErrors

        public static void runExpectingErrors​(java.lang.String program,
                                              java.lang.Class<? extends java.lang.Throwable> expectedExceptionType,
                                              java.lang.String... messageContents)
        Tests a program expecting an error, and checks its message contents.
        Parameters:
        program - the program to execute. It it ends in ".pt", it will be loaded as Protelis script from classpath
        expectedExceptionType - the type of exception to be thrown
        messageContents - the strings that the exception message must include
      • runFileWithMultipleRuns

        public static void runFileWithMultipleRuns​(java.lang.String file)
        Parameters:
        file - file to be tested
      • runFileWithMultipleRuns

        public static void runFileWithMultipleRuns​(java.lang.String file,
                                                   int min,
                                                   int max)
        Parameters:
        file - file to be tested
        min - min runs
        max - max runs
      • runFileWithMultipleRuns

        public static void runFileWithMultipleRuns​(java.lang.String file,
                                                   java8.util.stream.IntStream stream)
        Parameters:
        file - file to be tested
        stream - stream of run
      • runFile

        public static void runFile​(java.lang.String file,
                                   int runs)
        Parameters:
        file - file to be tested
        runs - number of runs
      • runFile

        public static void runFile​(java.lang.String file,
                                   int runs,
                                   java.lang.Object expectedResult)
        Parameters:
        file - file to be tested
        runs - number of runs
        expectedResult - expected result
      • runProgram

        public static java.lang.Object runProgram​(java.lang.String s,
                                                  int runs)
        Parameters:
        s - program to run
        runs - number of runs
        Returns:
        program result