Skip to main content



      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 07:59 Go to next message
Eclipse UserFriend
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 08:07] by 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 08:49 Go to previous messageGo to next message
Eclipse UserFriend
simply make sure you load all resources to the resourceset and call both standalonesetups
Re: Writing unit tests for a DSL that is referencing a DSL [message #1785627 is a reply to message #1785608] Tue, 17 April 2018 11:04 Go to previous messageGo to next message
Eclipse UserFriend
Hi Lukas,

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

Re: Writing unit tests for a DSL that is referencing a DSL [message #1785772 is a reply to message #1785627] Thu, 19 April 2018 09:56 Go to previous message
Eclipse UserFriend
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: Thu Jun 19 00:35:02 EDT 2025

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

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

Back to the top