Skip to content

Commit 542d3ee

Browse files
committed
new \pgfmathparse tests
1 parent 223b445 commit 542d3ee

File tree

5 files changed

+702
-0
lines changed

5 files changed

+702
-0
lines changed

MANIFEST

+4
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,7 @@ t/55_theorem.t
831831
t/56_ams.t
832832
t/65_graphics.t
833833
t/66_pgf.tt
834+
t/661_pgfmathparse.t
834835
t/67_tikz.tt
835836
t/70_parse.t
836837
t/80_complex.t
@@ -1638,6 +1639,9 @@ t/pgf/stress_pgfmath.xml
16381639
t/pgf/stress_pgfplots.pdf
16391640
t/pgf/stress_pgfplots.tex
16401641
t/pgf/stress_pgfplots.xml
1642+
t/pgfmathparse/pgfmathparse.pdf
1643+
t/pgfmathparse/pgfmathparse.tex
1644+
t/pgfmathparse/pgfmathparse.xml
16411645
t/post/hyperref-post.xml
16421646
t/post/hyperref.xml
16431647
t/post/simplemath-post.xml

t/661_pgfmathparse.t

+10
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/pgfmathparse.pdf

67.2 KB
Binary file not shown.

t/pgfmathparse/pgfmathparse.tex

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

0 commit comments

Comments
 (0)