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 |
Hannes Müller 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 |
|
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
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
| |
Re: Testing the parser and the semantic model [message #894720 is a reply to message #894575] |
Tue, 10 July 2012 09:25 |
|
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
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| |
Goto Forum:
Current Time: Tue Sep 24 18:34:06 GMT 2024
Powered by FUDForum. Page generated in 0.03693 seconds
|