Debian Codegraph @

texmf-dist/tex/generic/pgfplots/test/pgfplots.assert.code.tex

raw
1
2 % Token-wise equals; will expand arguments with \edef
3 % #1: expected
4 % #2: actual
5 % #3: message
6 \def\pgfplotsassertequalstok#1#2#3{%
7 \edef\pgfplots@assert@a{#1}%
8 \edef\pgfplots@assert@b{#2}%
9 \pgfplotscommandtostring\pgfplots@assert@a\pgfplots@assert@a
10 \pgfplotscommandtostring\pgfplots@assert@b\pgfplots@assert@b
11 \ifx\pgfplots@assert@a\pgfplots@assert@b
12 \else
13 \pgfplotsassertfail{#3 ^^Jexpected '#1'^^J but was '#2'}%
14 \fi
15 }%
16
17 % Token-wise equals of two MACROS; no expansion
18 % #1: expected
19 % #2: actual
20 % #3: message
21 \def\pgfplotsassertequalstoknoexpand#1#2#3{%
22 \ifx#1#2%
23 \else
24 \pgfplotsassertfail{#3 expected ^^J '\meaning#1' but was ^^J '\meaning#2'}%
25 \fi
26 }%
27
28 \def\pgfplotsassertfail#1{%
29 \pgfplots@error{Assertion failed: #1}%
30 }%
31
32 % Float-equals
33 % #1: expected
34 % #2: actual
35 % #3: message
36 \def\pgfplotsassertequalsfloat#1#2#3{%
37 \edef\pgfplots@assert@a{#1}%
38 \edef\pgfplots@assert@b{#2}%
39 %
40 \pgfmathfloatparsenumber{\pgfplots@assert@a}%
41 \let\pgfplots@assert@a\pgfmathresult
42 %
43 \pgfmathfloatparsenumber{\pgfplots@assert@b}%
44 \let\pgfplots@assert@b\pgfmathresult
45 %
46 \pgfmathfloatifapproxequalrel{\pgfplots@assert@a}{\pgfplots@assert@b}{%
47 }{%
48 \pgfplotsassertfail{#3 ^^Jexpected '#1'^^J but was '#2'}%
49 }%
50 }%