Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ValidateTestHelper.asserError arguments
ValidateTestHelper.asserError arguments [message #1753312] Fri, 03 February 2017 16:58 Go to next message
Greg Lusk is currently offline Greg LuskFriend
Messages: 36
Registered: February 2017
Location: USA
Member
I am fairly new to Xtext, and am trying to write a unit test to assert that an error occurs in deliberately bad syntax. I'm not exactly sure how to pass the second (EClass) argument to the function call. Can anyone post an example and explain how to specify a value for this argument?

Thanks
Re: ValidateTestHelper.asserError arguments [message #1753560 is a reply to message #1753312] Tue, 07 February 2017 17:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14730
Registered: July 2009
Senior Member
Can you be more specific about the kind of error / validation you want to test

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: ValidateTestHelper.asserError arguments [message #1753648 is a reply to message #1753312] Wed, 08 February 2017 13:15 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
In Xtext, an EClass is the type of an element in your AST. The 'E' stands for Ecore, which offers a bit higher-level description of types than Java.
If you use a generated Ecore model (that's the default), the EClasses are defined by the rules in your grammar, e.g.

grammar ...

generate myEcore "http:..." // will result in an EPackage 'myEcore'

Foo: // will result in an EClass 'Foo'
'foo' name=ID; // will result in an EAttribute 'name'

Will result in an EClass 'Foo' with and EAttribute 'name' of type 'EString'.
Once you run the workflow, the code generator will derive an Ecore model with the EClasses from your grammar. Then it will run the EMF code generator to generate Java classes from the Ecore model.

If you need to access an EClass, e.g. to pass it to the ValidationTestHelper, you find it as a singleton in the generated EPackage class. In our case
MyEcorePackage.eINSTANCE.getFoo()
or
MyEcorePackage.Literals.FOO
If you have an element of the AST in your hands, use
myObject.eClass()


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:Troubles With Parsing Numbers
Next Topic:Adding definition in global scope provider
Goto Forum:
  


Current Time: Tue Nov 12 09:47:59 GMT 2024

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

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

Back to the top