|
| 1 | +\documentclass{article} |
| 2 | +\usepackage{pgf} |
| 3 | +% ifthenelse will force LaTeXML to use the grammar instead of eval, because it is blacklisted |
| 4 | +\makeatletter |
| 5 | +\def\test{\begingroup\pgfmath@catcodes\@ifnextchar[\test@\test@@} |
| 6 | +\def\test@[#1]#2{\texttt{#1 = \pgfmathprint{#2} = \pgfmathprint{ifthenelse(1,#2,"never")}}\endgroup\par} |
| 7 | +\def\test@@#1{\test@[#1]{#1}} |
| 8 | +\makeatother |
| 9 | +\begin{document} |
| 10 | + |
| 11 | +\section{94.1.1 Commands} |
| 12 | +\test{2pt+3.5pt} |
| 13 | +\test{sin(.5*pi r)*60} |
| 14 | +\test{1.234e+4} |
| 15 | +\test{010} |
| 16 | +\test{0xA} |
| 17 | +\test{0XB} |
| 18 | +\test{0b10} |
| 19 | +\test{0B101} |
| 20 | +% partially implemented: quotes |
| 21 | + |
| 22 | +\section{92.2 Operators} |
| 23 | +\test{1+2} |
| 24 | +\test{1-2} |
| 25 | +\test{-2} |
| 26 | +\test{1*2} |
| 27 | +\test{1/2} |
| 28 | +% correct, but generates 'Script ^ can only appear in math mode' error |
| 29 | +\test[2\^3]{2^3} |
| 30 | +\test{4!} |
| 31 | +\test{1r} |
| 32 | +\test{pi r} |
| 33 | +\test{1 ? 2 : 3} |
| 34 | +\test{2 == 2} |
| 35 | +\test{2 == 1} |
| 36 | +\test{(1+2)*3} |
| 37 | +\test{sin(30*10)} |
| 38 | +\test{mod(72,3)} |
| 39 | +\test{sin 30} |
| 40 | +\test{sin(30)} |
| 41 | +\test{sin 30*10} |
| 42 | +\test{sin(30)*10} |
| 43 | +% unimplemented: array operator {X} |
| 44 | +% unimplemented: array access operator [X] |
| 45 | +5 is {\pgfmathprint{ifthenelse(5 > 7,"\noexpand\Large Bigger","\noexpand\tiny smaller")} than 7.} |
| 46 | + |
| 47 | +5 is {\pgfmathprint{5 > 7 ? "\noexpand\Large Bigger" : "\noexpand\tiny smaller"} than 7.} |
| 48 | + |
| 49 | +7 is {\pgfmathprint{ifthenelse(7 > 5,"\noexpand\Large Bigger","\noexpand\tiny smaller")} than 5.} |
| 50 | + |
| 51 | +7 is {\pgfmathprint{7 > 5 ? "\noexpand\Large Bigger" : "\noexpand\tiny smaller"} than 5} |
| 52 | + |
| 53 | +\section{92.3 Functions} |
| 54 | + |
| 55 | +\subsection{92.3.1 Basic arithmetic functions} |
| 56 | +\test{add(75,6)} |
| 57 | +\test{subtract(75,6)} |
| 58 | +\test{neg(50)} |
| 59 | +\test{multiply(75,6)} |
| 60 | +\test{divide(75,6)} |
| 61 | +\test{div(75,9)} |
| 62 | +\test{factorial(5)} |
| 63 | +\test{sqrt(10)} |
| 64 | +\test{sqrt(8765.432)} |
| 65 | +\test{pow(2,7)} |
| 66 | +\test[e\^2 - e\^-2]{(e^2 - e^-2)/2} |
| 67 | +\test{exp(1)} |
| 68 | +\test{exp(2.34)} |
| 69 | +\test{ln(10)} |
| 70 | +\test{ln(exp(5))} |
| 71 | +\test{log10(100)} |
| 72 | +\test{log2(128)} |
| 73 | +\test{abs(-5)} |
| 74 | +\test{-abs(4*-3)} |
| 75 | +\test{mod(20,6)} |
| 76 | +\test{mod(-100,30)} |
| 77 | +\test{Mod(-100,30)} |
| 78 | +\test{sign(-5)} |
| 79 | +\test{sign(0)} |
| 80 | +\test{sign(5)} |
| 81 | + |
| 82 | +\subsection{94.3.2 Rounding functions} |
| 83 | +\test{round(32.5/17)} |
| 84 | +\test{round(398/12)} |
| 85 | +\test{floor(32.5/17)} |
| 86 | +\test{floor(398/12)} |
| 87 | +\test{floor(-398/12)} |
| 88 | +\test{ceil(32.5/17)} |
| 89 | +\test{ceil(398/12)} |
| 90 | +\test{ceil(-398/12)} |
| 91 | +\test{int(32.5/17)} |
| 92 | +\test{frac(32.5/17)} |
| 93 | +\test{int(-32.5/17)} % added in LaTeXML to check behavior on negative numbers |
| 94 | +\test{frac(-32.5/17)} % added in LaTeXML to check behavior on negative numbers |
| 95 | +\test{real(4)} |
| 96 | + |
| 97 | +\subsection{94.3.3 Integer arithmetic functions} |
| 98 | +% FAILS \test{gcd(42,56)} |
| 99 | +\test{isodd(2)} |
| 100 | +\test{isodd(3)} |
| 101 | +\test{iseven(2)} |
| 102 | +\test{iseven(3)} |
| 103 | +\test{isprime(1)} |
| 104 | +\test{isprime(2)} |
| 105 | +\test{isprime(31)} |
| 106 | +\test{isprime(64)} |
| 107 | + |
| 108 | +\subsection{94.3.4 Trigonometric functions} |
| 109 | +\test{pi} |
| 110 | +\test{pi r} |
| 111 | +\test{rad(90)} |
| 112 | +\test{deg(3*pi/2)} |
| 113 | +\test{sin(60)} |
| 114 | +% WRONG \test{sin(pi/3 r)} |
| 115 | +\test{cos(60)} |
| 116 | +% WRONG \test{cos(pi/3 r)} |
| 117 | +\test{tan(45)} |
| 118 | +% WRONG \test{tan(2*pi/8 r)} |
| 119 | +\test{sec(45)} |
| 120 | +\test{cosec(30)} |
| 121 | +\test{cot(15)} |
| 122 | + |
| 123 | +\subsection{94.3.5 Comparison and logical functions} |
| 124 | +% infix versions added by LaTeXML to check parsing |
| 125 | +\test{equal(20,20)} |
| 126 | +\test{20 == 20} |
| 127 | +\test{greater(20,25)} |
| 128 | +\test{20 > 25} |
| 129 | +\test{less(20,25)} |
| 130 | +\test{20 < 25} |
| 131 | +\test{notequal(20,25)} |
| 132 | +\test{20 != 25} |
| 133 | +\test{notgreater(20,25)} |
| 134 | +\test{20 <= 25} |
| 135 | +\test{notless(20,25)} |
| 136 | +\test{20 >= 25} |
| 137 | +\test{and(5>4,6>7)} |
| 138 | +\test{5>4 && 6>7} |
| 139 | +\test{or(5>4,6>7)} |
| 140 | +\test{5>4 || 6>7} |
| 141 | +\test{not(true)} |
| 142 | +\test{! true} |
| 143 | +\test{not(false)} % added in LaTeXML to check parsing |
| 144 | +\test{! false} % added in LaTeXML to check parsing |
| 145 | +\test{ifthenelse(5==4,"yes","no")} |
| 146 | +\test{5==4 ? "yes" : "no"} |
| 147 | +\test{true ? "yes" : "no"} |
| 148 | +\test{false ? "yes" : "no"} |
| 149 | + |
| 150 | +\subsection{94.3.6 Pseudo-random functions} |
| 151 | +% unimplemented: determinism (yet) |
| 152 | + |
| 153 | +\subsection{94.3.7 Base conversion functions} |
| 154 | +\test{hex(65535)} |
| 155 | +\test{Hex(65535)} |
| 156 | +\test{oct(63)} |
| 157 | +% perl thinks this is a number and yields an overflow error |
| 158 | +% FAILS \test{bin(185)} |
| 159 | + |
| 160 | +\subsection{94.3.8 Miscellaneous functions} |
| 161 | +\test{min(3,4,-2,250,-8,100)} |
| 162 | +\test{max(3,4,-2,250,-8,100)} |
| 163 | +\test{veclen(12,5)} |
| 164 | +% unimplemented: arrays |
| 165 | +\test{sinh(0.5)} |
| 166 | +\test{cosh(0.5)} |
| 167 | +\test{tanh(0.5)} |
| 168 | +\test{width("Some Lovely Text")} |
| 169 | +\test{height("Some Lovely Text")} |
| 170 | +\test{depth("Some Lovely Text")} |
| 171 | + |
| 172 | +\end{document} |
0 commit comments