Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMT (Generative Modeling Technologies) » [xtext] testing the parser
[xtext] testing the parser [message #384429] Sun, 03 August 2008 09:29 Go to next message
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1260
Registered: July 2009
Senior Member
Hi

I've just started to take a look at this technology which looks really
cool, but I was wondering how to test the parser (I mean unit tests)...

thanks in advance
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
Re: [xtext] testing the parser [message #384652 is a reply to message #384429] Fri, 08 August 2008 02:39 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven Efftinge
Messages: 1755
Registered: July 2009
Senior Member
public void testSimple() throws Exception {
InputStream in = new StringInputStream("instance (of) { my dsl }");
Node rootNode = new XtextParser(model).getRootNode();
EObject modelElement = rootNode.getModelElement();
assert(....)
}

Note that it is a good idea to use EMF's generator in order to have
static types instead of using EMF's refelection layer for assertions.

Sven


Lorenzo Bettini schrieb:
> Hi
>
> I've just started to take a look at this technology which looks really
> cool, but I was wondering how to test the parser (I mean unit tests)...
>
> thanks in advance
> Lorenzo
>


--
Have you heard about XtextCON?
Go to: http://www.xtextcon.org
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [xtext] testing the parser [message #384655 is a reply to message #384652] Fri, 08 August 2008 05:11 Go to previous message
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1260
Registered: July 2009
Senior Member
Sven Efftinge wrote:
>
> public void testSimple() throws Exception {
> InputStream in = new StringInputStream("instance (of) { my dsl }");
> Node rootNode = new XtextParser(model).getRootNode();
> EObject modelElement = rootNode.getModelElement();
> assert(....)
> }
>
> Note that it is a good idea to use EMF's generator in order to have
> static types instead of using EMF's refelection layer for assertions.
>

mhh... sorry Sven, but I'm not sure I understand this part... I should
not use EObject right? Then what should I use?

thanks
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
Re: [xtext] testing the parser [message #618906 is a reply to message #384429] Fri, 08 August 2008 02:39 Go to previous message
Sven Efftinge is currently offline Sven Efftinge
Messages: 1755
Registered: July 2009
Senior Member
public void testSimple() throws Exception {
InputStream in = new StringInputStream("instance (of) { my dsl }");
Node rootNode = new XtextParser(model).getRootNode();
EObject modelElement = rootNode.getModelElement();
assert(....)
}

Note that it is a good idea to use EMF's generator in order to have
static types instead of using EMF's refelection layer for assertions.

Sven


Lorenzo Bettini schrieb:
> Hi
>
> I've just started to take a look at this technology which looks really
> cool, but I was wondering how to test the parser (I mean unit tests)...
>
> thanks in advance
> Lorenzo
>


--
Have you heard about XtextCON?
Go to: http://www.xtextcon.org
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: [xtext] testing the parser [message #618911 is a reply to message #384652] Fri, 08 August 2008 05:11 Go to previous message
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1260
Registered: July 2009
Senior Member
Sven Efftinge wrote:
>
> public void testSimple() throws Exception {
> InputStream in = new StringInputStream("instance (of) { my dsl }");
> Node rootNode = new XtextParser(model).getRootNode();
> EObject modelElement = rootNode.getModelElement();
> assert(....)
> }
>
> Note that it is a good idea to use EMF's generator in order to have
> static types instead of using EMF's refelection layer for assertions.
>

mhh... sorry Sven, but I'm not sure I understand this part... I should
not use EObject right? Then what should I use?

thanks
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
Previous Topic:how to put oaw projects on CVS
Next Topic:[xtext] How to use the generated ecore file?
Goto Forum:
  


Current Time: Thu Apr 24 01:55:16 EDT 2014

Powered by FUDForum. Page generated in 0.14014 seconds