-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for reporting errors in imports
This is a follow-up from #143, which was fixing an issue that we did not detect due to not having tests to check how we report errors in imports.
- Loading branch information
1 parent
3092361
commit d8328f8
Showing
2 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...test.acceptance/src/org/eclipse/epsilon/eol/engine/test/acceptance/ParseProblemTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2024 The University of York. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
package org.eclipse.epsilon.eol.engine.test.acceptance; | ||
|
||
import static org.hamcrest.CoreMatchers.allOf; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
|
||
import org.eclipse.epsilon.eol.EolModule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class ParseProblemTests { | ||
|
||
@Rule | ||
public TemporaryFolder tempFolder = new TemporaryFolder(); | ||
|
||
private static final String BAD_EOL = "'incomplete string"; | ||
|
||
@Test | ||
public void missingImport() throws Exception { | ||
EolModule module = new EolModule(); | ||
module.parse("import \"missing.eol\";"); | ||
assertEquals(1, module.getParseProblems().size()); | ||
assertThat("Expected parse problem is raised", | ||
module.getParseProblems().get(0).getReason(), | ||
allOf( | ||
containsString("not found"), | ||
containsString("missing.eol") | ||
)); | ||
} | ||
|
||
@Test | ||
public void parseProblemsLocal() throws Exception { | ||
EolModule module = new EolModule(); | ||
module.parse(BAD_EOL); | ||
assertEquals(1, module.getParseProblems().size()); | ||
} | ||
|
||
@Test | ||
public void parseProblemsImported() throws Exception { | ||
File fParseProblems = tempFolder.newFile("parseProblems.eol"); | ||
Files.write(fParseProblems.toPath(), BAD_EOL.getBytes()); | ||
|
||
EolModule module = new EolModule(); | ||
module.parse(String.format("import \"%s\";", fParseProblems.getPath())); | ||
assertEquals(1, module.getParseProblems().size()); | ||
assertThat("Expected parse problem is raised", | ||
module.getParseProblems().get(0).getReason(), | ||
allOf( | ||
containsString("contains errors"), | ||
containsString("parseProblems.eol") | ||
)); | ||
} | ||
|
||
} |