Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test that uses an XML input grammar #158

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions fn/invisible-xml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,29 @@
<assert-xml><![CDATA[<date><year>2023</year><month>10</month><day>31</day></date>]]></assert-xml>
</result>
</test-case>

<test-case name="invisible-xml-003">
<description>Simple date grammar as XML</description>
<created by="Norm Tovey-Walsh" on="2024-08-29"/>
<test>
let $grammar := <![CDATA[parse-xml("<ixml><rule name='date'><alt><nonterminal name='year'/>
<literal tmark='-' string='-'/><nonterminal name='month'/><literal tmark='-' string='-'/>
<nonterminal name='day'/></alt></rule><rule name='year'><alt><nonterminal name='d'/>
<nonterminal name='d'/><nonterminal name='d'/><nonterminal name='d'/></alt></rule>
<rule name='month'><alt><literal string='0'/><nonterminal name='d'/></alt><alt>
<literal string='1'/><inclusion><member string='0'/><member string='1'/><member string='2'/>
</inclusion></alt></rule><rule name='day'><alt><inclusion><member string='0'/>
<member string='1'/><member string='2'/></inclusion><nonterminal name='d'/></alt>
<alt><literal string='3'/><inclusion><member string='0'/><member string='1'/>
</inclusion></alt></rule><rule mark='-' name='d'><alt><inclusion>
<member from='0' to='9'/></inclusion></alt></rule></ixml>")]]>
let $parse := invisible-xml($grammar)
return $parse("2023-10-31")
</test>
<result>
<assert-xml><![CDATA[<date><year>2023</year><month>10</month><day>31</day></date>]]></assert-xml>
</result>
</test-case>

<test-case name="invisible-xml-901">
<description>Bad grammar, fail-on-error=true</description>
Expand Down