Skip to content
Snippets Groups Projects
Select Git revision
2 results Searching

expected_tar_content

Blame
  • Forked from stgroup / trainbenchmark
    Source project has a limited visibility.
    ParserTest.java 2.09 KiB
    package de.tudresden.inf.st.mg;
    
    import de.tudresden.inf.st.mg.common.MotionGrammarParser;
    import de.tudresden.inf.st.mg.jastadd.model.*;
    import org.junit.jupiter.api.BeforeAll;
    import org.junit.jupiter.api.Test;
    
    import java.io.File;
    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Path;
    import java.util.Comparator;
    import java.util.Random;
    
    import static org.assertj.core.api.Assertions.assertThat;
    
    public class ParserTest {
    
      public static final Path LOAD_AST_DIAGRAM_DIR = Path.of("src", "gen", "resources", "diagrams", "parsing", "load");
      public static final Path TIDY_AST_DIAGRAM_DIR = Path.of("src", "gen", "resources", "diagrams", "parsing", "tidy");
    
      @BeforeAll
      static void prepareOutputPath() throws IOException {
        try {
          Files.walk(LOAD_AST_DIAGRAM_DIR).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
        } catch (IOException e) {
          // do nothing
        }
        try {
          Files.walk(TIDY_AST_DIAGRAM_DIR).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
        } catch (IOException e) {
          // do nothing
        }
        Files.createDirectories(LOAD_AST_DIAGRAM_DIR);
        Files.createDirectories(TIDY_AST_DIAGRAM_DIR);
      }
    
      @Test
      void runLodUnloadParser() throws MotionGrammarParser.ParseException {
    
        // for some reason, the best random seed value here is 1 and not 0???
        Container containerWorld = Container.initialWorld(new Random(1));
    
        LoadWorldParser parser = new LoadWorldParser(containerWorld);
        parser.setDebugDiagramDir(LOAD_AST_DIAGRAM_DIR);
    
        var result = parser.parse();
    
        assertThat(result).isNotNull().isInstanceOf(T1.class);
      }
    
      @Test
      void runTidyParser() throws MotionGrammarParser.ParseException {
    
    // for some reason, the best random seed value here is 1 and not 0???
    World world = RobotScene.initialWorld(new Random(1));
    
    // create a parser using the world
    RobotParser parser = new RobotParser(world);
    parser.setDebugDiagramDir(TIDY_AST_DIAGRAM_DIR);
    
    // parse (synchonously, long-running)
    var result = parser.parse();
    
    assertThat(result).isNotNull().isInstanceOf(Tidy.class);
      }
    
    }