Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
blob: c2a4442f98ccb503f2ccbd7df948ed8efac5e1ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?xml version="1.0"?>
<!--
  Copyright (C) 2014-2019 Ryan Specialty Group, 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="Testing minimum and maximum values of vectors">

  <import package="../../spec" />

  <import package="../../../base" />
  <import package="../../../vector/filter" />
  <import package="../../../vector/stub" />


  <const name="VFILTER_MASK_NONE" type="integer"
         desc="4-vector masking nothing">
    <item value="1" desc="First set" />
    <item value="1" desc="Second set" />
    <item value="1" desc="Third set" />
    <item value="1" desc="Fourth set" />
  </const>

  <const name="VFILTER_MASK_MIDDLE" type="integer"
         desc="4-vector with middle elements unmasked">
    <item value="0" desc="First unset" />
    <item value="1" desc="Second set" />
    <item value="1" desc="Third set" />
    <item value="0" desc="Fourth unset" />
  </const>


  <t:describe name="_vfilter-mask_">
    <t:it desc="produces an empty vector given an empty vector">
      <t:given>
        <c:length-of>
          <!-- empty body with no @name@ -->
          <t:vfilter-mask mask="NVEC1">
          </t:vfilter-mask>
        </c:length-of>
      </t:given>

      <t:expect>
        <t:match-result eq="0" />
      </t:expect>
    </t:it>


    <t:it desc="acts as identity given an all-set mask">
      <t:given>
        <c:length-of>
          <t:vfilter-mask name="NVEC4_SEQ" mask="VFILTER_MASK_NONE" />
        </c:length-of>
      </t:given>

      <t:expect>
        <t:match-result eq="4" />
      </t:expect>
    </t:it>


    <t:it desc="retains original vector values">
      <t:given>
        <c:let>
          <c:values>
            <c:value name="vec" type="integer" set="vector"
                     desc="Result">
              <t:vfilter-mask name="NVEC4_SEQ" mask="VFILTER_MASK_NONE" />
            </c:value>
          </c:values>

          <c:sum of="vec" />
        </c:let>
      </t:given>

      <t:expect>
        <!-- 0 + 1 + 2 + 3 (NVEC4_SEQ) -->
        <t:match-result eq="6" />
      </t:expect>
    </t:it>


    <t:it desc="produces empty vector given all-unset mask">
      <t:given>
        <c:length-of>
          <!-- NVEC4 is a 4-vector of 0s -->
          <t:vfilter-mask name="NVEC4_SEQ" mask="NVEC4" />
        </c:length-of>
      </t:given>

      <t:expect>
        <t:match-result eq="0" />
      </t:expect>
    </t:it>


    <t:describe name="given a partly set mask">
      <t:it desc="removes masked vector elements">
        <t:given>
          <c:length-of>
            <t:vfilter-mask name="NVEC4_SEQ" mask="VFILTER_MASK_MIDDLE" />
          </c:length-of>
        </t:given>

        <t:expect>
          <t:match-result eq="2" />
        </t:expect>
      </t:it>


      <t:it desc="retains value of original vector elements">
        <t:given>
          <c:let>
            <c:values>
              <c:value name="vec" type="integer" set="vector"
                       desc="Result">
                <t:vfilter-mask name="NVEC4_SEQ" mask="VFILTER_MASK_MIDDLE" />
              </c:value>
            </c:values>

            <c:sum of="vec" />
          </c:let>
        </t:given>

        <t:expect>
          <!-- 1 + 2 -->
          <t:match-result eq="3" />
        </t:expect>
      </t:it>


      <!-- same as above, but inline -->
      <t:it desc="masks inline vectors">
        <t:given>
          <c:let>
            <c:values>
              <c:value name="vec" type="integer" set="vector"
                       desc="Result">
                <!-- inline values -->
                <t:vfilter-mask mask="VFILTER_MASK_MIDDLE">
                  <c:value-of name="#10" />
                  <c:value-of name="#12" />
                  <c:value-of name="#14" />
                  <c:value-of name="#16" />
                </t:vfilter-mask>
              </c:value>
            </c:values>

            <c:sum of="vec" />
          </c:let>
        </t:given>

        <t:expect>
          <!-- 12 + 14 -->
          <t:match-result eq="26" />
        </t:expect>
      </t:it>
    </t:describe>
  </t:describe>
</package>