Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Sense in testing the parser and the semantic model If using Xtext
Sense in testing the parser and the semantic model If using Xtext [message #894575] Mon, 09 July 2012 16:43 Go to next message
Hannes Müller is currently offline Hannes MüllerFriend
Messages: 24
Registered: June 2012
Junior Member
Hello everyone,

Okay, this is a more theoretical question. In the DSL book from Fowler, in the "Modellgetriebene Softwareentwicklung" book of Stahl, Völter, ... and also in some Xtext tutorials two tests are descriped: testing the parser and the semantic model. But I don't really understand why I should test the parser if using Xtext? Does this mean, that I check if the xtext developers implemented the parser bug free??
The second question is the testing of the semantic model: Let us have a look at the Example of the book "Modellgetriebene Softwareentwicklung".

// model
Entity A{ ..., ref manyToMany B[]}
Entity B{ ..., ref manyToMany A[]}

// test
public void testManyToMany(){
A a = new A();
B b = new B();
b.addToManyToMany(b);
assertTrue(b.getManyToMany().contains(a));
}

I also don't really get why I have to test this? Do I here again test against Xtext implementation (because in Xtext this would be an EList and the adding of elements to this list is all code which is generated of Xtext in those Impl-Classes). Or is it only because of the "test first thought"?

Thx for any enlightenment (maybe I am only slow on the uptake right now ^^)
Hannes

[Updated on: Mon, 09 July 2012 16:44]

Report message to a moderator

Re: Testing the parser and the semantic model [message #894589 is a reply to message #894575] Mon, 09 July 2012 17:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
Registered: July 2009
Senior Member
Hmmm,

the Voelter Stahl book must be some year old.
never the less: testing the parser tells you if you did the grammar right.

from the snipped you posted i cannot really say/see what is done.
it seems to be a test of generated code -
which of course makes sense to. (generated by the code generator you
have written)
maybe you have a typo here and

> a.addToManyToMany(b);
> assertTrue(b.getManyToMany().contains(a));

or

> b.addToManyToMany(a);
> assertTrue(b.getManyToMany().contains(a));

is correct

~Christian

On 2012-07-09 16:43:26 +0000, Hannes Müller said:

> Hello everyone,
>
> Okay, this is a more theoretical question. In the DSL book from Fowler,
> in the "Modellgetriebene Softwareentwicklung" book of Stahl, Völter,
> ... and also in some Xtext tutorials two tests are descriped: testing
> the parser and the semantic model. But I don't really understand why I
> should test the parser if using Xtext? Does this mean, that I check if
> the xtext developers implemented the parser bug free??
> The second question is the testing of the semantic model: Let us have a
> look at the Example of the book "Modellgetriebene Softwareentwicklung".
>
> // model
> Entity A{ ..., ref manyToMany B[]}
> Entity B{ ..., ref manyToMany A[]}
>
> // test
> public void testManyToMany(){
> A a = new A();
> B b = new B();
> b.addToManyToMany(b);
> assertTrue(b.getManyToMany().contains(a));
> }
>
> I also don't really get why I have to test this? Do I here again test
> against Xtext implementation (because in Xtext this would be an EList
> and the adding of elements to this list is all code which is generated
> of Xtext in those Impl-Classes). Or is it only because of the "test
> first thought"?
>
> Thx for any enlightenment (maybe I am only slow on the uptake right now ^^)
> Hannes


--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@xxxxxxxx


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Testing the parser and the semantic model [message #894600 is a reply to message #894589] Mon, 09 July 2012 19:23 Go to previous messageGo to next message
Hannes Müller is currently offline Hannes MüllerFriend
Messages: 24
Registered: June 2012
Junior Member
Hello Christian,

First thanks for the answer and yes it is a typo...

Hm, okay I think I got this parser test: You just give the test a dsl-string and after that you say this model element instances should occur with this attributes and this values.

Ok, thx again. I still am not hundert procently sure what is ment with this semantic model test though ...

Hannes



Re: Testing the parser and the semantic model [message #894720 is a reply to message #894575] Tue, 10 July 2012 09:25 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1762
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

as for parser tests one use case could be testing that you got
associativity right, for instance for expressions (e.g.,
http://sourceforge.net/p/xsemantics/code/ci/d7a91d986237063fb1accdddeadcf7f79ae68458/tree/examples/it.xsemantics.example.expressions.tests/src/it/xsemantics/example/expressions/tests/ExpressionsParserTests.xtend?force=True
)

On 07/09/2012 06:43 PM, Hannes Müller wrote:
> Hello everyone,
>
> Okay, this is a more theoretical question. In the DSL book from Fowler,
> in the "Modellgetriebene Softwareentwicklung" book of Stahl, Völter, ...
> and also in some Xtext tutorials two tests are descriped: testing the
> parser and the semantic model. But I don't really understand why I
> should test the parser if using Xtext? Does this mean, that I check if
> the xtext developers implemented the parser bug free??
> The second question is the testing of the semantic model: Let us have a
> look at the Example of the book "Modellgetriebene Softwareentwicklung".
>
> // model
> Entity A{ ..., ref manyToMany B[]}
> Entity B{ ..., ref manyToMany A[]}
>
> // test
> public void testManyToMany(){
> A a = new A();
> B b = new B();
> b.addToManyToMany(b);
> assertTrue(b.getManyToMany().contains(a));
> }
>
> I also don't really get why I have to test this? Do I here again test
> against Xtext implementation (because in Xtext this would be an EList
> and the adding of elements to this list is all code which is generated
> of Xtext in those Impl-Classes). Or is it only because of the "test
> first thought"?
>
> Thx for any enlightenment (maybe I am only slow on the uptake right now ^^)
> Hannes


--
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: Testing the parser and the semantic model [message #894751 is a reply to message #894720] Tue, 10 July 2012 11:12 Go to previous message
Hannes Müller is currently offline Hannes MüllerFriend
Messages: 24
Registered: June 2012
Junior Member
Hi Lorenzo,

Thx for the hint Smile I will discuss that with my colleague if I need those tests with with my dsl.

I think that the thread can be closed for now.
Hannes
Previous Topic:using format effector character in a terminal rule
Next Topic:Xtext runtime with Java Runtime Environment 1.5 ?
Goto Forum:
  


Current Time: Wed Feb 26 05:01:00 GMT 2020

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

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

Back to the top