AbstractSemanticAdaptationGeneratorTest.xtend 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * generated by Xtext 2.10.0
  3. */
  4. package be.uantwerpen.ansymo.semanticadaptation.tests
  5. import com.google.inject.Inject
  6. import org.eclipse.xtext.generator.IGenerator2
  7. import org.junit.Assert
  8. import org.eclipse.xtext.generator.InMemoryFileSystemAccess
  9. import org.eclipse.xtext.generator.IFileSystemAccess
  10. import be.uantwerpen.ansymo.semanticadaptation.semanticAdaptation.SemanticAdaptation
  11. abstract class AbstractSemanticAdaptationGeneratorTest extends AbstractSemanticAdaptationParserTest {
  12. @Inject IGenerator2 generator
  13. InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess()
  14. /**
  15. * Generates an output file in the file system using the DSL's code generation
  16. */
  17. def void generateOutputFile(SemanticAdaptation root) {
  18. //println(root.statements)
  19. //println(root.imports)
  20. generator.doGenerate(root.eResource, this.fsa, null)
  21. }
  22. /**
  23. * Compares a given file in memory to the given oracle file
  24. */
  25. def void compareFiles(String inmemoryfilename, String oraclefilename) {
  26. //println(this.fsa.allFiles)
  27. Assert.assertTrue(inmemoryfilename + " not found", this.fsa.allFiles.containsKey(inmemoryfilename))
  28. val actualtext = fsa.allFiles.get(inmemoryfilename)
  29. val expectedtext = readFile('oracles/'+oraclefilename)
  30. Assert.assertEquals(expectedtext, actualtext)
  31. }
  32. }