use of com.vladsch.flexmark.util.options.DataHolder in project flexmark-java by vsch.
the class DumpSpecReader method addSpecExample.
@Override
protected void addSpecExample(SpecExample example) {
DataHolder options;
boolean ignoredCase = false;
try {
options = testCase.getOptions(example, example.getOptionsSet());
} catch (AssumptionViolatedException ignored) {
ignoredCase = true;
options = null;
}
if (options != null && options.get(FAIL)) {
ignoredCase = true;
}
String parseSource = example.getSource();
if (options != null && options.get(RenderingTestCase.NO_FILE_EOL)) {
parseSource = trimTrailingEOL(parseSource);
}
Node node = testCase.parser().withOptions(options).parse(parseSource);
final String actualHTML = testCase.renderer().withOptions(options).render(node);
final String actualAST = testCase.ast(node);
String html = !ignoredCase && testCase.useActualHtml() ? actualHTML : example.getHtml();
String ast = example.getAst() == null ? null : (!ignoredCase ? actualAST : example.getAst());
// allow other formats to accumulate
testCase.addSpecExample(example, node, options, ignoredCase, actualHTML, actualAST);
// include source so that diff can be used to update spec
addSpecExample(sb, example.getSource(), html, ast, example.getOptionsSet(), testCase.includeExampleCoords(), example.getSection(), example.getExampleNumber());
}
use of com.vladsch.flexmark.util.options.DataHolder in project flexmark-java by vsch.
the class RenderingTestCase method assertRendering.
protected void assertRendering(String source, String expectedHtml, String optionsSet) {
DataHolder options = optionsSet == null ? null : getOptions(example(), optionsSet);
String parseSource = source;
if (options != null && options.get(NO_FILE_EOL)) {
parseSource = DumpSpecReader.trimTrailingEOL(parseSource);
}
Node node = parser().withOptions(options).parse(parseSource);
String html = renderer().withOptions(options).render(node);
testCase(node, options);
actualHtml(html, optionsSet);
boolean useActualHtml = useActualHtml();
// include source for better assertion errors
String expected;
String actual;
if (example() != null && example().getSection() != null) {
StringBuilder outExpected = new StringBuilder();
DumpSpecReader.addSpecExample(outExpected, source, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
expected = outExpected.toString();
StringBuilder outActual = new StringBuilder();
DumpSpecReader.addSpecExample(outActual, source, useActualHtml ? html : expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
actual = outActual.toString();
} else {
expected = DumpSpecReader.addSpecExample(source, expectedHtml, "", optionsSet);
actual = DumpSpecReader.addSpecExample(source, useActualHtml ? html : expectedHtml, "", optionsSet);
}
specExample(expected, actual, optionsSet);
if (options != null && options.get(FAIL)) {
thrown.expect(ComparisonFailure.class);
}
assertEquals(expected, actual);
}
use of com.vladsch.flexmark.util.options.DataHolder in project flexmark-java by vsch.
the class ComboAppHtmlParserTest method assertRendering.
// reverse source and html
@Override
protected void assertRendering(String source, String expectedHtml, String optionsSet) {
DataHolder options = optionsSet == null ? null : getOptions(example(), optionsSet);
String parseSource = expectedHtml;
if (options != null && options.get(NO_FILE_EOL)) {
parseSource = DumpSpecReader.trimTrailingEOL(parseSource);
}
Node node = parser().withOptions(options).parse(parseSource);
String renderedResult = renderer().withOptions(options).render(node);
String expectedResult = source;
actualSource(renderedResult, optionsSet);
boolean useActualHtml = useActualHtml();
// include source for better assertion errors
String expected;
String actual;
if (example() != null && example().getSection() != null) {
StringBuilder outExpected = new StringBuilder();
DumpSpecReader.addSpecExample(outExpected, expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
expected = outExpected.toString();
StringBuilder outActual = new StringBuilder();
DumpSpecReader.addSpecExample(outActual, useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
actual = outActual.toString();
} else {
expected = DumpSpecReader.addSpecExample(expectedResult, expectedHtml, "", optionsSet);
actual = DumpSpecReader.addSpecExample(useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet);
}
specExample(expected, actual, optionsSet);
if (options != null && options.get(FAIL)) {
thrown.expect(ComparisonFailure.class);
}
assertEquals(expected, actual);
}
use of com.vladsch.flexmark.util.options.DataHolder in project flexmark-java by vsch.
the class ComboFlexmarkHtmlAttributesParserTest method assertRendering.
// reverse source and html
@Override
protected void assertRendering(String source, String expectedHtml, String optionsSet) {
DataHolder options = optionsSet == null ? null : getOptions(example(), optionsSet);
String parseSource = expectedHtml;
if (options != null && options.get(NO_FILE_EOL)) {
parseSource = DumpSpecReader.trimTrailingEOL(parseSource);
}
Node node = parser().withOptions(options).parse(parseSource);
String renderedResult = renderer().withOptions(options).render(node);
String expectedResult = source;
actualSource(renderedResult, optionsSet);
boolean useActualHtml = useActualHtml();
// include source for better assertion errors
String expected;
String actual;
if (example() != null && example().getSection() != null) {
StringBuilder outExpected = new StringBuilder();
DumpSpecReader.addSpecExample(outExpected, expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
expected = outExpected.toString();
StringBuilder outActual = new StringBuilder();
DumpSpecReader.addSpecExample(outActual, useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
actual = outActual.toString();
} else {
expected = DumpSpecReader.addSpecExample(expectedResult, expectedHtml, "", optionsSet);
actual = DumpSpecReader.addSpecExample(useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet);
}
specExample(expected, actual, optionsSet);
if (options != null && options.get(FAIL)) {
thrown.expect(ComparisonFailure.class);
}
assertEquals(expected, actual);
}
use of com.vladsch.flexmark.util.options.DataHolder in project flexmark-java by vsch.
the class ComboFlexmarkHtmlParserTest method assertRendering.
// reverse source and html
@Override
protected void assertRendering(String source, String expectedHtml, String optionsSet) {
DataHolder options = optionsSet == null ? null : getOptions(example(), optionsSet);
String parseSource = expectedHtml;
if (options != null && options.get(NO_FILE_EOL)) {
parseSource = DumpSpecReader.trimTrailingEOL(parseSource);
}
Node node = parser().withOptions(options).parse(parseSource);
String renderedResult = renderer().withOptions(options).render(node);
String expectedResult = source;
actualSource(renderedResult, optionsSet);
boolean useActualHtml = useActualHtml();
// include source for better assertion errors
String expected;
String actual;
if (example() != null && example().getSection() != null) {
StringBuilder outExpected = new StringBuilder();
DumpSpecReader.addSpecExample(outExpected, expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
expected = outExpected.toString();
StringBuilder outActual = new StringBuilder();
DumpSpecReader.addSpecExample(outActual, useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet, true, example().getSection(), example().getExampleNumber());
actual = outActual.toString();
} else {
expected = DumpSpecReader.addSpecExample(expectedResult, expectedHtml, "", optionsSet);
actual = DumpSpecReader.addSpecExample(useActualHtml ? renderedResult : expectedResult, expectedHtml, "", optionsSet);
}
specExample(expected, actual, optionsSet);
if (options != null && options.get(FAIL)) {
thrown.expect(ComparisonFailure.class);
}
assertEquals(expected, actual);
}
Aggregations