2015-03-24 10:11:54 -04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<!--
|
2022-05-03 14:14:29 -04:00
|
|
|
Copyright (C) 2014-2022 Ryan Specialty Group, LLC.
|
2015-03-24 10:11:54 -04:00
|
|
|
|
|
|
|
This file is part of tame-core.
|
|
|
|
|
|
|
|
tame-core is free software: you can redistribute it and/or modify it
|
2018-01-26 11:13:33 -05:00
|
|
|
under the terms of the GNU General Public License as
|
2015-03-24 10:11:54 -04:00
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-->
|
|
|
|
<package xmlns="http://www.lovullo.com/rater"
|
2015-03-24 10:48:37 -04:00
|
|
|
xmlns:t="http://www.lovullo.com/rater/apply-template"
|
2015-03-24 10:11:54 -04:00
|
|
|
core="true"
|
|
|
|
desc="Assertions">
|
|
|
|
|
2015-03-24 10:48:37 -04:00
|
|
|
<import package="base" />
|
2018-01-09 15:23:01 -05:00
|
|
|
<import package="vector/cmatch" export="true" />
|
2015-03-24 10:48:37 -04:00
|
|
|
|
2018-01-09 14:56:21 -05:00
|
|
|
|
|
|
|
This package is young;
|
|
|
|
the intent is to provide basic assertions to ensure data
|
|
|
|
integrity.
|
|
|
|
|
|
|
|
\emph{N.B. The behavior of this package changed in version 1.0.0---%
|
|
|
|
\ref{_assert_} now properly fails on non-match,
|
|
|
|
not match.}
|
2015-03-24 10:11:54 -04:00
|
|
|
|
2015-03-24 10:48:37 -04:00
|
|
|
The \ref{_assert_} template generates a~generic assertion using the
|
2018-01-09 14:56:21 -05:00
|
|
|
provided predicates.
|
|
|
|
If the predicates provided to the assertion fail (yields $\bot$),
|
|
|
|
the system immediately terminates.\footnote{
|
|
|
|
Beacuse the system stops processing once a terminating classification
|
|
|
|
yields~$\top$,
|
|
|
|
only one assertion will ever match,
|
|
|
|
even if others would match if execution were to continue.}
|
2018-01-12 09:36:07 -05:00
|
|
|
\tt{@class@} may optionally be used to predicate the asseriton itself---%
|
|
|
|
the assertion will be performed only on respective class matches.
|
2018-01-09 14:56:21 -05:00
|
|
|
|
|
|
|
\ref{_assert_} implements assertions by genearting two classifications---%
|
|
|
|
one to perform the actual assertion,
|
|
|
|
and a terminating classification to ensure that the assertion
|
|
|
|
yields~$\top$.
|
2015-03-24 10:11:54 -04:00
|
|
|
|
2018-03-20 14:50:43 -04:00
|
|
|
The param \ref{assert_ignore} will suppress assertion failures at runtime.
|
|
|
|
|
|
|
|
<param name="assert_ignore" type="boolean" default="0"
|
|
|
|
desc="Ignore assertion failures" />
|
|
|
|
|
|
|
|
|
2015-03-24 10:48:37 -04:00
|
|
|
<template name="_assert_"
|
|
|
|
desc="Terminate on predicate failure">
|
|
|
|
<param name="@values@" desc="Predicates" />
|
2015-03-24 10:11:54 -04:00
|
|
|
|
|
|
|
<param name="@as@" desc="Generated classification name">
|
2015-03-24 10:48:37 -04:00
|
|
|
<text unique="true">-assert-</text>
|
2015-03-24 10:11:54 -04:00
|
|
|
</param>
|
|
|
|
|
2018-01-11 11:23:52 -05:00
|
|
|
<param name="@failure@" desc="Failure description">
|
2018-01-09 14:56:21 -05:00
|
|
|
<text>Assertion</text>
|
2015-03-24 10:11:54 -04:00
|
|
|
</param>
|
|
|
|
|
2018-01-12 09:36:07 -05:00
|
|
|
<param name="@class@" desc="Only perform assertion for respective class
|
|
|
|
matches (optional)" />
|
|
|
|
|
2018-01-09 14:56:21 -05:00
|
|
|
|
2018-09-10 14:04:21 -04:00
|
|
|
<param name="@neg-as@"
|
2018-01-09 14:56:21 -05:00
|
|
|
desc="Generated name for classification to be negated">
|
|
|
|
<text unique="true">-nassert-</text>
|
|
|
|
</param>
|
2018-09-10 14:04:21 -04:00
|
|
|
<param name="@neg-yields@"
|
2018-01-09 14:56:21 -05:00
|
|
|
desc="Generated yield for classification to be negated">
|
|
|
|
<text unique="true">_nassert</text>
|
2015-03-24 10:48:37 -04:00
|
|
|
</param>
|
2015-03-24 10:11:54 -04:00
|
|
|
|
2018-09-10 14:14:34 -04:00
|
|
|
<param name="@neg-desc@" desc="Description for negative classification">
|
|
|
|
<param-value name="@failure@" />
|
|
|
|
<text> (assertion result)</text>
|
|
|
|
</param>
|
|
|
|
|
2015-03-24 10:11:54 -04:00
|
|
|
|
2018-01-09 14:56:21 -05:00
|
|
|
<!-- The actual assertion will be performed by one classification... -->
|
2018-09-10 14:14:34 -04:00
|
|
|
<classify as="@neg-as@" yields="@neg-yields@" desc="@neg-desc@">
|
2018-01-12 09:36:07 -05:00
|
|
|
<any>
|
|
|
|
<!-- if class is provided and does not match, then the assertion
|
|
|
|
succeeds automatically -->
|
|
|
|
<if name="@class@">
|
|
|
|
<t:match-class name="@class@" value="FALSE" />
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<all>
|
|
|
|
<param-copy name="@values@" />
|
|
|
|
</all>
|
|
|
|
</any>
|
2018-01-09 14:56:21 -05:00
|
|
|
</classify>
|
2015-03-24 10:11:54 -04:00
|
|
|
|
2018-01-09 14:56:21 -05:00
|
|
|
<!-- ...which is in turn negated for the terminating
|
|
|
|
classification. The reason for this is that terminating
|
|
|
|
classifications terminate on _match_. -->
|
2015-03-24 10:11:54 -04:00
|
|
|
|
2018-01-11 11:23:52 -05:00
|
|
|
<classify as="@as@" desc="@failure@" terminate="true">
|
2018-03-20 14:50:43 -04:00
|
|
|
<match on="assert_ignore" value="FALSE" />
|
2018-09-10 14:04:21 -04:00
|
|
|
<match on="@neg-yields@" value="FALSE" />
|
2015-03-24 10:11:54 -04:00
|
|
|
</classify>
|
|
|
|
</template>
|
|
|
|
</package>
|