mbeckerle commented on code in PR #987:
URL: https://github.com/apache/daffodil/pull/987#discussion_r1908772194
##########
daffodil-test/src/test/resources/org/apache/daffodil/section07/discriminators/discriminator.tdml:
##########
@@ -765,13 +814,66 @@
<tdml:parserTestCase name="discrimExpression_04"
root="e3" model="discrimExpression"
- description="Property Name: test - DFDL-7-076R">
+ description="Verify that a discriminator will prevent backtracking
+ regardless of whether the sequence content parses succesfully">
<tdml:document><![CDATA[abc]]></tdml:document>
+ <tdml:errors>
+ <tdml:error>Parse Error</tdml:error>
+ <tdml:error>Failed to populate ex:ints</tdml:error>
+ <tdml:error>Unable to parse xs:int from text: a</tdml:error>
+ </tdml:errors>
+ </tdml:parserTestCase>
+
+ <tdml:parserTestCase name="discrimExpression_05"
+ root="e4" model="discrimExpression"
+ description="Verify that a failed discriminator will be handled correctly
+ when the body of the sequence parses successfully">
+ <tdml:document><![CDATA[123]]></tdml:document>
<tdml:infoset>
<tdml:dfdlInfoset>
- <e3>
+ <e4>
+ <string>123</string>
+ </e4>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+
+ <tdml:parserTestCase name="discrimExpression_06"
+ root="e4" model="discrimExpression"
+ description="Verify correct behavior when the body of a sequence fails and
+ the discriminator fails">
+ <tdml:document><![CDATA[abc]]></tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <e4>
<string>abc</string>
- </e3>
+ </e4>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+
+ <tdml:parserTestCase name="discrimExpression_07"
+ root="e5" model="discrimExpression"
+ description="Sequence body fails, but discriminator succeeds and references
+ elements in partial body infoset">
+ <tdml:document><![CDATA[1ab]]></tdml:document>
+ <tdml:errors>
+ <tdml:error>Parse Error</tdml:error>
+ <tdml:error>Failed to populate ex:ints</tdml:error>
+ <tdml:error>Unable to parse xs:int from text: a</tdml:error>
Review Comment:
Add a check that the message contains the element name "int2" since that is
the one that should be causing the failure.
##########
daffodil-test/src/test/resources/org/apache/daffodil/section07/discriminators/discriminator.tdml:
##########
@@ -765,13 +814,66 @@
<tdml:parserTestCase name="discrimExpression_04"
root="e3" model="discrimExpression"
- description="Property Name: test - DFDL-7-076R">
+ description="Verify that a discriminator will prevent backtracking
+ regardless of whether the sequence content parses succesfully">
<tdml:document><![CDATA[abc]]></tdml:document>
+ <tdml:errors>
+ <tdml:error>Parse Error</tdml:error>
+ <tdml:error>Failed to populate ex:ints</tdml:error>
+ <tdml:error>Unable to parse xs:int from text: a</tdml:error>
+ </tdml:errors>
+ </tdml:parserTestCase>
+
+ <tdml:parserTestCase name="discrimExpression_05"
+ root="e4" model="discrimExpression"
+ description="Verify that a failed discriminator will be handled correctly
+ when the body of the sequence parses successfully">
+ <tdml:document><![CDATA[123]]></tdml:document>
<tdml:infoset>
<tdml:dfdlInfoset>
- <e3>
+ <e4>
+ <string>123</string>
+ </e4>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+
+ <tdml:parserTestCase name="discrimExpression_06"
+ root="e4" model="discrimExpression"
+ description="Verify correct behavior when the body of a sequence fails and
+ the discriminator fails">
+ <tdml:document><![CDATA[abc]]></tdml:document>
+ <tdml:infoset>
+ <tdml:dfdlInfoset>
+ <e4>
<string>abc</string>
- </e3>
+ </e4>
+ </tdml:dfdlInfoset>
+ </tdml:infoset>
+ </tdml:parserTestCase>
+
+ <tdml:parserTestCase name="discrimExpression_07"
+ root="e5" model="discrimExpression"
+ description="Sequence body fails, but discriminator succeeds and references
+ elements in partial body infoset">
+ <tdml:document><![CDATA[1ab]]></tdml:document>
+ <tdml:errors>
+ <tdml:error>Parse Error</tdml:error>
+ <tdml:error>Failed to populate ex:ints</tdml:error>
+ <tdml:error>Unable to parse xs:int from text: a</tdml:error>
+ </tdml:errors>
+ </tdml:parserTestCase>
+
+ <tdml:parserTestCase name="discrimExpression_08"
Review Comment:
Yes. Verified. This does appear to cover it. I added one comment about
tightening up the error message since the error should be talking specifically
about the int2 field being the one that failed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]