tame/core/test/core/vector/length.xml

144 lines
3.7 KiB
XML

<?xml version="1.0"?>
<!--
Copyright (C) 2014-2023 Ryan Specialty, LLC.
This file is part of tame-core.
tame-core is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as
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"
xmlns:c="http://www.lovullo.com/calc"
xmlns:t="http://www.lovullo.com/rater/apply-template"
desc="Interpolation specs">
<import package="../../spec" />
<import package="../../../base" />
<import package="../../../vector/length" />
<t:describe name="_first-nonempty_">
<t:describe name="given no vectors">
<t:it desc="yields an empty vector">
<t:given>
<c:length-of>
<t:first-nonempty />
</c:length-of>
</t:given>
<t:expect>
<t:match-result>
<c:eq>
<c:value-of name="#0" />
</c:eq>
</t:match-result>
</t:expect>
</t:it>
</t:describe>
<t:describe name="given only one empty vector">
<t:it desc="yields an empty vector">
<t:given>
<c:length-of>
<t:first-nonempty>
<c:vector />
</t:first-nonempty>
</c:length-of>
</t:given>
<t:expect>
<t:match-result>
<c:eq>
<c:value-of name="#0" />
</c:eq>
</t:match-result>
</t:expect>
</t:it>
</t:describe>
<t:describe name="given only empty vectors">
<t:it desc="yields an empty vector">
<t:given>
<c:length-of>
<t:first-nonempty>
<c:vector />
<c:vector />
</t:first-nonempty>
</c:length-of>
</t:given>
<t:expect>
<t:match-result>
<c:eq>
<c:value-of name="#0" />
</c:eq>
</t:match-result>
</t:expect>
</t:it>
</t:describe>
<t:describe name="given first empty vector with non-empty">
<t:it desc="yields the second vector">
<t:given>
<c:car>
<t:first-nonempty>
<c:vector />
<c:vector>
<c:const value="50" desc="Non-empty vector" />
</c:vector>
</t:first-nonempty>
</c:car>
</t:given>
<t:expect>
<t:match-result>
<c:eq>
<c:value-of name="#50" />
</c:eq>
</t:match-result>
</t:expect>
</t:it>
</t:describe>
<t:describe name="given two non-empty vectors">
<t:it desc="yields the first vector">
<t:given>
<c:car>
<t:first-nonempty>
<c:vector>
<c:const value="60" desc="Non-empty vector" />
</c:vector>
<c:vector>
<c:const value="70" desc="Non-empty vector" />
</c:vector>
</t:first-nonempty>
</c:car>
</t:given>
<t:expect>
<t:match-result>
<c:eq>
<c:value-of name="#60" />
</c:eq>
</t:match-result>
</t:expect>
</t:it>
</t:describe>
</t:describe>
</package>