Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Writing unit tests for a DSL that is referencing a DSL
Writing unit tests for a DSL that is referencing a DSL [message #1785601] Tue, 17 April 2018 11:59 Go to next message
Lukas Schaus is currently offline Lukas SchausFriend
Messages: 37
Registered: October 2016
Member
Hello Everyone,

i followed Christian's Blogpost in order to cross-reference elements from one DSL in another DSL.

I need that since I have two DSL's that use the same definitions. So I figured it would be neat to have a DSL which handles the definitions and the both other DSLs can reference the Definitions DSL.

Let me provide a minimal example: I have two Grammars: Defs and Usages:

The Defs grammar looks like this:
grammar com.mydsl.defines.MDefines with org.eclipse.xtext.common.Terminals
generate mDefines "http://www.mydsl.com/defines/MDefines"

Model:
	defines+=Def*;
	
Def:
	'def' name=ID
;


The Usage grammar looks like this:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

import "http://www.mydsl.com/defines/MDefines" as def

Model:
	usages+=Usage*
	
;
Usage:
	'use' elem=[def::Def]
;


Now I would like to write a simple parsing unit test for the usage grammar in the usage project. How could I do that?

[Updated on: Tue, 17 April 2018 12:07]

Report message to a moderator

Re: Writing unit tests for a DSL that is referencing a DSL [message #1785608 is a reply to message #1785601] Tue, 17 April 2018 12:49 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
simply make sure you load all resources to the resourceset and call both standalonesetups

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Writing unit tests for a DSL that is referencing a DSL [message #1785627 is a reply to message #1785608] Tue, 17 April 2018 15:04 Go to previous messageGo to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 177
Registered: July 2009
Location: Canada
Senior Member
Hi Lukas,

This might help - https://www.eclipse.org/forums/index.php/m/1701469/#msg_1701469



Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Re: Writing unit tests for a DSL that is referencing a DSL [message #1785772 is a reply to message #1785627] Thu, 19 April 2018 13:56 Go to previous message
Lukas Schaus is currently offline Lukas SchausFriend
Messages: 37
Registered: October 2016
Member
Thank you Christian and Neeraj,
your answers seem to address my problems perfectly. I didnt have the chance to try it out but I will let you know when I did.

Previous Topic:Registering both relative and fully qualified name in Scope
Next Topic:Dynamic scoping based on ecore reflection and information in the runtime
Goto Forum:
  


Current Time: Fri Mar 29 06:47:16 GMT 2024

Powered by FUDForum. Page generated in 0.02315 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top