-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed oversized parser * Cleaned * Autoclrf * Autoclrf false * Made test lineending agnostic
- Loading branch information
1 parent
ba2bf09
commit f320ef7
Showing
8 changed files
with
47,628 additions
and
0 deletions.
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
46 changes: 46 additions & 0 deletions
46
...g/src/test/java/com/regnosys/rosetta/xcore/extractor/ParserCaseExtractorFragmentTest.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,46 @@ | ||
package com.regnosys.rosetta.xcore.extractor; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.eclipse.xtext.xtext.generator.XtextGenerator; | ||
import org.eclipse.xtext.xtext.generator.XtextGeneratorLanguage; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.google.common.io.Files; | ||
|
||
public class ParserCaseExtractorFragmentTest { | ||
@Test | ||
public void testParserCaseExtractorFragment() throws IOException { | ||
File source = new File("src/test/resources/extractor-test/Parser.java"); | ||
File target = new File("target/extractor-test/Parser.java"); | ||
target.getParentFile().mkdirs(); | ||
Files.copy(source, target); | ||
|
||
ParserCaseExtractorFragment fragment = new ParserCaseExtractorFragment(); | ||
fragment.addGrammarFile(target.toString()); | ||
|
||
XtextGeneratorLanguage lang = new XtextGeneratorLanguage(); | ||
lang.addReferencedResource("platform:/resource/com.regnosys.rosetta/model/Rosetta.xcore"); | ||
lang.addReferencedResource("platform:/resource/com.regnosys.rosetta/model/RosettaSimple.xcore"); | ||
lang.addReferencedResource("platform:/resource/com.regnosys.rosetta/model/RosettaExpression.xcore"); | ||
lang.setGrammarUri(new File("src/main/java", "com.regnosys.rosetta.Rosetta".replace(".", "/") + ".xtext").toURI().toString()); | ||
lang.addFragment(fragment); | ||
|
||
XtextGenerator generator = new XtextGenerator(); | ||
generator.addLanguage(lang); | ||
generator.initialize(); | ||
|
||
fragment.generate(); | ||
|
||
File expected = new File("src/test/resources/extractor-test/ExpectedOutputParser.java"); | ||
|
||
assertEquals( | ||
Files.asCharSource(expected, StandardCharsets.UTF_8).read().replace("\r\n", "\n"), | ||
Files.asCharSource(target, StandardCharsets.UTF_8).read().replace("\r\n", "\n") | ||
); | ||
} | ||
} |
Oops, something went wrong.