Example #1
0
  @Test
  public void verify_compile_error_uninitialized() throws IOException, ParseException {
    String errSourceFileDir = "src/test/resources/for-test/";
    GoloCompiler compiler = new GoloCompiler();
    GoloCompilationException.Problem problem;

    String errSourceFile = "uninitialized-reference-lookup.golo";
    try {
      compiler.compile(errSourceFile, new FileInputStream(errSourceFileDir + errSourceFile));
    } catch (GoloCompilationException e) {
      assertThat(e.getMessage(), is("In Golo module: " + errSourceFile));
      assertThat(e.getSourceCode(), is(errSourceFile));
      assertThat(e.getProblems().size(), is(2));

      problem = e.getProblems().get(0);
      assertThat(
          problem.getType(),
          is(GoloCompilationException.Problem.Type.UNINITIALIZED_REFERENCE_ACCESS));
      assertThat(problem.getSource().getLineInSourceCode(), is(4));
      assertThat(problem.getSource().getColumnInSourceCode(), is(13));

      problem = e.getProblems().get(1);
      assertThat(
          problem.getType(),
          is(GoloCompilationException.Problem.Type.UNINITIALIZED_REFERENCE_ACCESS));
      assertThat(problem.getSource().getLineInSourceCode(), is(5));
      assertThat(problem.getSource().getColumnInSourceCode(), is(20));
    }
  }
Example #2
0
  @Test
  public void verify_compile_error_incomplete() throws IOException, ParseException {
    String errSourceFileDir = "src/test/resources/for-test/";
    GoloCompiler compiler = new GoloCompiler();
    GoloCompilationException.Problem problem;

    String errSourceFile = "incomplete.golo";
    try {
      compiler.compile(errSourceFile, new FileInputStream(errSourceFileDir + errSourceFile));
    } catch (GoloCompilationException e) {
      assertThat(e.getMessage(), is("In Golo module: " + errSourceFile));
      assertThat(e.getSourceCode(), is(errSourceFile));
      assertThat(e.getProblems().size(), is(1));

      problem = e.getProblems().get(0);
      assertThat(problem.getType(), is(GoloCompilationException.Problem.Type.PARSING));
      assertThat(problem.getSource().getLineInSourceCode(), is(3));
    }
  }