|
|
|
Re: Newline formatting wrong [message #1777985 is a reply to message #1777983] |
Thu, 07 December 2017 10:44 |
|
how do you test formatting.
class XbaseFormatterTester extends FormatterTester {
def void assertFormattedExpression((FormatterTestRequest)=>void test) {
val prefix = "{" + Strings.newLine
val postfix = Strings.newLine + "}"
val (FormatterTestRequest)=>void setup = [
test.apply(it)
preferences[
put(FormatterPreferenceKeys.maxLineWidth, 80)
]
expectation = prefix + expectationOrToBeFormatted.toString.trim.indent("\t") + postfix
toBeFormatted = prefix + toBeFormatted.toString.trim.indent("\t") + postfix
]
assertFormatted(setup)
}
as you can see FormatterTestRequest allows to set preferences
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: Newline formatting wrong [message #1777987 is a reply to message #1777985] |
Thu, 07 December 2017 11:05 |
Udo Walker Messages: 48 Registered: January 2013 |
Member |
|
|
I just use a plain test class with these annotations:
@RunWith(XtextRunner)
@InjectWith(Fop2InjectorProvider)
class FO2FormatterTest extends Assert {
and these injections
@Inject
extension ParseHelper<Model>
@Inject
extension ISerializer
And the test looks like this:
assertEquals(expected, input.parse.serialize(SaveOptions.newBuilder.format().getOptions()))
where expected is the expected formatted string and input is the unformatted string.
Is there some documentation on how to use the FormatterTestHelper ?
[Updated on: Thu, 07 December 2017 11:14] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03606 seconds