VerifyTools
Bracket
create a verification suitable for testing addressable structures
Calling Sequence
Parameters
Description
Examples
VerifyTools:-Bracket(ver)
ver
-
verification; verification to bracket
The Bracket command brackets a verification, ver, by converting it to a verification suitable for testing the content of an addressable structure that has been wrapped in list brackets.
Bracket(ver) expands dummy verifications %NULL, seq, and &, in ver, as explained on verify,exprseq.
%NULL verifies empty expression sequences.
seq(ver) verifies expression sequences of ver verifications.
(ver1 &, ver2 &, ver3 ... ) verifies expression sequences using ver1 for the first element, etc.
This procedure is used by the verifications Array, Matrix, Vector, rtable, record, and table, when an optional verification is specified.
with⁡VerifyTools:
Suppose we want to parametric verification which compares two Vectors, where each entry of the Vector is either NULL or an expression sequence of two entries. In the latter case, we want to compare the first expression of the sequence exactly, and the second expression using the verification passed as a parameter, either the as_set verification, which ignores the order and multiplicity of the results, or the as_list verification which does not.
v≔Vector⁡2:
v1≔1,2,6,4:
v2≔NULL:
w≔Vector⁡2:
w1≔1,2,4,4,6:
w2≔NULL:
v,w
1,2,6,4,1,2,4,4,6
my_verification := proc(v1, v2, ver, $) if not (v1 :: Vector and v2 :: Vector) then return false; elif numelems(v1) <> numelems(v2) then return false; end if; for local i to numelems(v1) do if not verify([v1[i]], [v2[i]], Bracket({(truefalse &, ver), %NULL})) then return false; end if; end do; return true; end proc;
my_verification ≔ procv1,v2,ver, $locali;ifnotv1::Vectorandv2::Vectorthenreturnfalseelifnumelems⁡v1<>numelems⁡v2thenreturnfalseend if;foritonumelems⁡v1doifnotverify⁡v1[i],v2[i],VerifyTools:-Bracket⁡%NULL,truefalse &, verthenreturnfalseend ifend do;returntrueend proc
AddVerification⁡my_Vector,my_verification
verify⁡v,w,my_Vector⁡as_set
true
verify⁡v,w,my_Vector⁡as_list
false
See Also
VerifyTools[AddVerification]
Download Help Document