Compiler tests for multi-DSLs? [message #1780733] |
Fri, 26 January 2018 11:53 |
Martin Trummer Messages: 17 Registered: December 2017 |
Junior Member |
|
|
I found some nice resources how to use 2 DSLs: e.g.
That also helped me to get all parsing tests working.
Example:
in project xtext-multi-dsl we have MyDslA which does not know anything about MyDslB.
MyDslB on the other hand imports MyDslA (and thus depends on MyDslA).
In this case I can write a simple compiler tests-working for the MyDslA.
But how can we write compiler tests for the MyDslB (which is dependent on MyDslA)?
e.g. I think I'd need to:
- first load the sub-dsl model file
- trigger the sub-dsl generator
- put the generated files on the classpath
- load the super-dsl model file
- and finally generate and check the generated super-dsl files
Maybe there is already some example project for such tests?
[Updated on: Fri, 26 January 2018 12:36] Report message to a moderator
|
|
|
|
|
Re: Compiler tests for multi-DSLs? [message #1780738 is a reply to message #1780736] |
Fri, 26 January 2018 13:01 |
|
same as your other questions. have a look at the compilation test helper code and improvise ....
@RunWith(XtextRunner)
@InjectWith(DomainmodelInjectorProvider2)
class CompilerTest {
static class DomainmodelInjectorProvider2 extends DomainmodelInjectorProvider {
override protected internalCreateInjector() {
XtendStandaloneSetup.doSetup
super.internalCreateInjector()
}
}
@Rule
@Inject public TemporaryFolder temporaryFolder
@Inject extension CompilationTestHelper
@Inject extension ReflectExtensions
@Test
def void testGeneratedJavaFromSeveralInputs() {
resourceSet(#[
"a.dmodel" -> '''
entity Foo {
bar : Bar
op doStuff(String x) : String {
return x + ' ' + bar.getName()
}
}
''',
"b.dmodel" ->'''
entity Bar extends Bat {
name : String
}
''',
"Bat.xtend" -> '''
class Bat {}'''
]).compile [
Assert.assertEquals(''''''.toString, singleGeneratedCode)
]
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.03862 seconds