Skip to content

Commit 55f2867

Browse files
committed
new \pgfmathparse tests
1 parent cd372e5 commit 55f2867

File tree

4 files changed

+564
-0
lines changed

4 files changed

+564
-0
lines changed

t/661_pgfmathparse.t

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- CPERL -*-
2+
#**********************************************************************
3+
# Test cases for LaTeXML
4+
#**********************************************************************
5+
use LaTeXML::Util::Test;
6+
7+
latexml_tests("t/pgfmathparse",
8+
requires=>{
9+
pgfmathparse=>{
10+
packages=>'pgf.sty'} });

t/pgfmathparse/pgffunctions.pdf

43.7 KB
Binary file not shown.

t/pgfmathparse/pgffunctions.tex

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

0 commit comments

Comments
 (0)