1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
|
\documentclass{article}
\makeatletter
\usepackage{pgf}
\usepgflibrary{luamath,fpu}
\begin{document}
X
\def\SHOW#1{%
\dimen0=#1 %
#1 = \the\dimen0
}
\SHOW{1pt}
\SHOW{1mm}
\SHOW{1cm}
\SHOW{1in}
\SHOW{1ex}
\SHOW{1em}
\SHOW{1bp}
\SHOW{1pc}
\SHOW{1dd}
\SHOW{1cc}
\SHOW{1sp}
%\tracingmacros=2 \tracingcommands=2
%
\newif\ifcomparewithtex
\newif\ifcomparewithfpu
\pgfkeys{
/ut/compare with TeX/.is if=comparewithtex,
/ut/compare with TeX=true,
/ut/compare with fpu/.is if=comparewithfpu,
/ut/compare with fpu=true,
/ut/.search also={/pgf/luamath},
/pgf/luamath/show error message=true,
/pgf/luamath/enable TeX fallback=false,
}
\newcount\numErrors
% #1: options
% #2: expression
% #3: expected result
% #4: expected 'units declared' (1 or 0)
\def\parsertest{\pgfutil@ifnextchar[\parsertest@{\parsertest@[]}}%
\def\parsertest@[#1]#2#3#4{%
\begingroup
\pgfqkeys{/ut}{#1}%
\pgfluamathparse{#2}%
\let\actual=\pgfmathresult
\ifpgfmathunitsdeclared
\def\actualunitsdeclared{1}%
\else
\def\actualunitsdeclared{0}%
\fi
%
\ifcomparewithtex
\ifpgfluamathusedTeXfallback
\let\expectedTeX=\actual
\else
\pgfmathparse{#2}%
\let\expectedTeX=\pgfmathresult
\fi
\else
\def\expectedTeX{--}%
\fi
%
\edef\expected{#3}%
\def\success{1}%
\ifx\expected\empty
\ifx\actual\empty
\else
\def\success{0}%
\fi
\else
\ifx\actual\expected
\else
\def\success{0}%
\fi
\fi
%
\if1\success
\else
\message{FAILURE for #2 expected \expected\space but was \actual^^J}%
\global\advance\numErrors by1
\fi
%
\if1\success
\def\expectedunitsdeclared{#4}%
\ifx\actualunitsdeclared\expectedunitsdeclared
\else
\def\success{0}%
\message{FAILURE for #2 expected units declared #4 but was \actualunitsdeclared^^J}%
\global\advance\numErrors by1
\fi
\fi
%
\if1\success
\ifcomparewithtex
% check against PGF's basic layer as reference:
\dimen0=\actual pt %
\dimen1=\expectedTeX pt %
\advance\dimen0 by-\dimen1
\ifdim\dimen0<0sp
\dimen0=-\dimen0
\fi
\ifdim\dimen0 > 0.004pt %
\def\success{0}%
\message{FAILURE for #2 : matches expectations, but does NOT match TeX output (error \the\dimen0). expected \expectedTeX\space but was \actual^^J}%
\global\advance\numErrors by1
\fi
%
%
\ifpgfmathunitsdeclared
\def\actualTeXunitsdeclared{1}%
\else
\def\actualTeXunitsdeclared{0}%
\fi
\ifx\actualTeXunitsdeclared\actualunitsdeclared
\else
\message{WARNING for #2 : matches ALL expectations, but TeX's output does NOT match TeX expected units declared (TeX returns \actualTeXunitsdeclared, expectation = LUA is \actualunitsdeclared)^^J}%
\fi
\fi
%
\ifcomparewithfpu
% check that FPU works as well. This
% * tests the FPU
% * tests that FPU values can be injected into the LUA backend:
\begingroup
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=float}%
\pgfmathparse{#2}%
\xdef\actualfpu{\pgfmathresult}%
\ifpgfmathunitsdeclared
\xdef\actualfpuunitsdeclared{1}%
\else
\xdef\actualfpuunitsdeclared{0}%
\fi
\endgroup
%
\pgfkeys{/pgf/luamath/output format=fixed}%
\pgfluamathparse{abs(\actual - \actualfpu) > 0.004}%
\ifdim\pgfmathresult pt=1pt
\def\success{0}%
\pgfluamathparse{abs(\actual - \actualfpu)}%
\message{FAILURE for #2 : matches expectations, but does NOT match output of FPU (error \pgfmathresult). fpu=\actualfpu\space lua=\actual^^J}%
\global\advance\numErrors by1
\fi
\fi
%
\fi
%
\message{#2 = \actual\space (pgf=\expectedTeX) \if1\success OK\else FAILURE\fi^^J}%
\endgroup
}%
\parsertest{1}{1.0}{0}
\parsertest{ 1}{1.0}{0}
\parsertest{-123}{-123.0}{0}
\parsertest{+123}{123.0}{0}
\parsertest{+1.23}{1.23}{0}
\parsertest{+.123}{0.123}{0}
\parsertest{1.23}{1.23}{0}
\parsertest{1.}{1.0}{0}
\parsertest{0.123}{0.123}{0}
\parsertest{.123}{0.123}{0}
\parsertest{1e4}{10000.0}{0}
\parsertest{1e-4}{0.0001}{0}
\parsertest{1e+4}{10000.0}{0}
% only supported by FPU
\parsertest[compare with TeX=false]{1Y1.23e4]}{12300.0}{0}
\parsertest{1.23e-004}{0.000123}{0}
\parsertest{004}{4.0}{0}
\parsertest{1 + 10}{11.0}{0}
\parsertest{1 - 10}{-9.0}{0}
\parsertest{(1)}{1.0}{0}
\parsertest{3 + 5*9 / (1+1) - 12}{13.5}{0}
\parsertest{pi}{3.141593}{0}
\parsertest{sin(0)}{0.0}{0}
\parsertest{max(0,1)}{1.0}{0}
\parsertest{min(0.01,-5)}{-5.0}{0}
\parsertest{sin(90)}{1.0}{0}
\parsertest{cos(90)}{0.0}{0}
\parsertest{pow(2,3)}{8.0}{0}
\parsertest{-pow(2,3)}{-8.0}{0}
\parsertest{-pi}{-3.141593}{0}
% this is actually UNSUPPORTED by TeX:
\parsertest[compare with TeX=false]{inf}{inf}{0}
\parsertest[compare with TeX=false]{INF}{inf}{0}
\parsertest{not(100)}{0.0}{0}% non-trivial since the function is pgfluamathfunctions.notPGF
\parsertest{2^2}{4.0}{0}
% only supported by FPU
\parsertest[compare with TeX=false]{1Y2.0e0]^2}{4.0}{0}
\parsertest{0-2^2}{-4.0}{0}
\parsertest{-2^2}{-4.0}{0}
\parsertest{pi^2}{9.869604}{0}
\parsertest{2^2+2}{6.0}{0}
\parsertest{2^2-1}{3.0}{0}
\parsertest{-1 + 4}{3.0}{0}
\parsertest{2^2*5}{20.0}{0}
\parsertest{2^(2+2)}{16.0}{0}
\parsertest{multiply(2,3)^2}{36.0}{0}
\parsertest{(2+3)^2}{25.0}{0}
\parsertest{(2 + 3 ) ^ 2}{25.0}{0}
\parsertest{2^add(1,1)}{4.0}{0}
\parsertest{3!}{6.0}{0}
\parsertest{1+3!}{7.0}{0}
\parsertest{2*3!}{12.0}{0}
\parsertest{3! + 1}{7.0}{0}
\parsertest{3 !}{6.0}{0}
\parsertest{3*2+4}{10.0}{0}
\pgfmathdeclarefunction{x}{0}{\def\pgfmathresult{4}}%
\pgfmathdeclarefunction{N1}{3}{\pgfmathparse{#1+#2+#3}}%
\directlua{
function pgfluamathfunctions.x()
return 4
end
function pgfluamathfunctions.N1(x,m,n)
return x+m+n
end
}
\parsertest{2^x}{16.0}{0}
\parsertest{exp(-x^2)}{0.0}{0} % requires output format=fpu
\parsertest{N1(1,2,3)}{6.0}{0}
\parsertest{ 1 + 2 * 4 ^ 2 }{33.0}{0}
\parsertest{-x + 4}{0.0}{0}
\parsertest{-x * 4}{-16.0}{0}
\parsertest{-x * - 4}{16.0}{0}
\parsertest{2*pi r}{360.0}{0}
\parsertest{6.28318530717959 r}{360.0}{0}
\parsertest{sin(2*pi r)}{-0.0}{0}
\parsertest{1.5707963267949r + 1.5707963267949r}{180.0}{0}
\parsertest{1 ? 42 : 0}{42.0}{0}
\parsertest{0 ? 42 : 0}{0.0}{0}
\parsertest{-1 + 1 ? 42 : 0}{0.0}{0}
\parsertest{1 + (1 ? 42 : 0)}{43.0}{0}
\parsertest{1 ? 42 : 0 ? 5 : 6}{5.0}{0}
\parsertest{(1 ? 42 : 0) ? 5 : 6}{5.0}{0}
\parsertest{43 == 43}{1.0}{0}
\parsertest{43 == 42}{0.0}{0}
\parsertest{43 != 43}{0.0}{0}
\parsertest{43 != 42}{1.0}{0}
\parsertest{43 > 42}{1.0}{0}
\parsertest{43 > 44}{0.0}{0}
\parsertest{43 < 42}{0.0}{0}
\parsertest{43 < 44}{1.0}{0}
\parsertest{43 <= 44}{1.0}{0}
\parsertest{43 >= 44}{0.0}{0}
\parsertest{43 >= 44 == 1}{0.0}{0}
\parsertest{!1}{0.0}{0}
\parsertest{! 1}{0.0}{0}
\parsertest{! -1}{0.0}{0}
\parsertest{--1}{1.0}{0}
\parsertest{! !1}{1.0}{0}
\parsertest{3! - !0}{5.0}{0}
\parsertest{1 && 1 }{1.0}{0}
\parsertest{1 && 0 || 1 }{1.0}{0}
\parsertest{1 && 0 && 1 }{0.0}{0}
\parsertest{1 || 0 }{1.0}{0}
\parsertest{0 || 0 || 1 }{1.0}{0}
% I test every function here to see that it is connected correctly
\parsertest{abs(1)}{1.0}{0}
\parsertest{add(1,2)}{3.0}{0}
\parsertest{and(1,1)}{1.0}{0}
% \parsertest{array(1)}{1.0}{0}
\parsertest{asin(0.7071)}{44.999451}{0}
\parsertest{atan(1)}{45.0}{0}
\parsertest{atan2(-4,3)}{-53.130102}{0}
% \parsertest{bin(1)}{1.0}{0}
\parsertest{cos(60)}{0.5}{0}
\parsertest{cosec(30)}{2.0}{0}
\parsertest{cosh(0.5)}{1.127626}{0}
\parsertest{cot(15)}{3.732051}{0}
\parsertest{deg(2*pi)}{360.0}{0}
% \parsertest{depth(1)}{1.0}{0}
\parsertest[compare with fpu=false]{div(1,2)}{0.0}{0}
\parsertest{divide(1,2)}{0.5}{0}
\parsertest{e}{2.718282}{0}
\parsertest{equal(1,2)}{0.0}{0}
\parsertest{factorial(3)}{6.0}{0}
\parsertest{false}{0.0}{0}
\parsertest{floor(0)}{0.0}{0}
\parsertest{floor(0.6)}{0.0}{0}
\parsertest{floor(1.6)}{1.0}{0}
\parsertest{floor(1)}{1.0}{0}
\parsertest{floor(100)}{100.0}{0}
\parsertest{floor(-100)}{-100.0}{0}
\parsertest{floor(-0.6)}{-1.0}{0}
\parsertest{floor(-1.6)}{-2.0}{0}
\parsertest{floor(-15000.6)}{-15001.0}{0}
\parsertest{floor(15000.6)}{15000.0}{0}
\parsertest{ceil(0)}{0.0}{0}
\parsertest{ceil(0.6)}{1.0}{0}
\parsertest{ceil(1.6)}{2.0}{0}
\parsertest{ceil(-0.6)}{-0.0}{0}
\parsertest{ceil(-1.6)}{-1.0}{0}
\parsertest{ceil(1)}{1.0}{0}
\parsertest{ceil(100)}{100.0}{0}
\parsertest{ceil(-100)}{-100.0}{0}
\parsertest{ceil(-15000.6)}{-15000.0}{0}
\parsertest{ceil(15000.6)}{15001.0}{0}
\parsertest[compare with fpu=false]{frac(1.1)}{0.1}{0}
\parsertest[compare with fpu=false]{frac(-1.1)}{0.1}{0}
\parsertest[compare with fpu=false]{gcd(42,56)}{14.0}{0}
\parsertest{greater(1,0)}{1.0}{0}
% \parsertest{height(1)}{1.0}{0}
% \parsertest{hex(1)}{1.0}{0}
% \parsertest{Hex(1)}{1.0}{0}
\parsertest{int(1.2)}{1.0}{0}
\parsertest{int(-1.2)}{-1.0}{0}
\parsertest{ifthenelse(1,2,3)}{2.0}{0}
\parsertest[compare with fpu=false]{iseven(2)}{1.0}{0}
\parsertest{isodd(1)}{1.0}{0}
\parsertest[compare with fpu=false]{isprime(3)}{1.0}{0}
\parsertest{less(1,2)}{1.0}{0}
\parsertest{ln(e)}{1.0}{0}
\parsertest{log10(100)}{2.0}{0}
\parsertest{log2(2)}{1.0}{0}
\parsertest{max(1,2)}{2.0}{0}
\parsertest{min(1,2)}{1.0}{0}
\parsertest{mod(20,6)}{2.0}{0}
\parsertest{mod(-100,30)}{-10.0}{0}
\parsertest[compare with fpu=false]{Mod(-100,30)}{20.0}{0}
\parsertest{multiply(1,2)}{2.0}{0}
\parsertest{neg(1)}{-1.0}{0}
\parsertest{not(1)}{0.0}{0}
\parsertest{notequal(1,1)}{0.0}{0}
\parsertest{notgreater(1,1)}{1.0}{0}
\parsertest{notless(1,1)}{1.0}{0}
%\parsertest{oct(1)}{1.0}{0}
\parsertest{or(1,0)}{1.0}{0}
\parsertest{pi}{3.141593}{0}
\parsertest{pow(2,2)}{4.0}{0}
\parsertest{rad(180)}{3.141593}{0}
% done below \parsertest{rand(1)}{1.0}{0}
% done below \parsertest{random(1)}{1.0}{0}
\parsertest[compare with fpu=false]{real(1)}{1.0}{0}
% done below \parsertest{rnd(1)}{1.0}{0}
\parsertest{round(1.5)}{2.0}{0}
\parsertest{round(1.2)}{1.0}{0}
\parsertest{round(1.9)}{2.0}{0}
\parsertest{round(-1.9)}{-2.0}{0}
\parsertest{round(-1.2)}{-1.0}{0}
% \parsertest{scalar(1)}{1.0}{0}
\parsertest{sec(45)}{1.414214}{0}
\parsertest{sign(-1)}{-1.0}{0}
\parsertest{sin(60)}{0.866025}{0}
\parsertest{sinh(0.5)}{0.521095}{0}
\parsertest{sqrt(4)}{2.0}{0}
\parsertest{subtract(1,1)}{0.0}{0}
\parsertest{tan(45)}{1.0}{0}
\parsertest{tanh(0.5)}{0.462117}{0}
\parsertest{true}{1.0}{0}
\parsertest{veclen(12,5)}{13.0}{0}
%\parsertest{width(1)}{1.0}{0}
\parsertest{0 <0.1 && 4 <0.1}{0.0}{0}
\parsertest{0 <0.1 || 4 <0.1}{1.0}{0}
{
\pgfkeys{/pgf/declare function={
xx=4;
yy=4;
}}
\parsertest{abs(xx-yy)<0.1 ? -42 : 42}{-42.0}{0}
\parsertest{abs(xx-yy)<0.1 || abs(xx-0.5)<0.1}{1.0}{0}
\parsertest{0 <0.1 || 4 <0.1}{1.0}{0}
\parsertest{(abs(xx-yy)<0.1) || (abs(xx-0.5)<0.1)}{1.0}{0}
\parsertest{abs(xx-yy)<0.1 || abs(xx-0.5)<0.1 ? -42 : 42}{-42.0}{0}
\parsertest{4 < 2 || 5==5 ? -42 : 42}{-42.0}{0}
}
\parsertest{1pt}{1.0}{1}
\parsertest{1mm}{2.845261}{1}
\parsertest{1cm}{28.452744}{1}
\parsertest{1in}{72.269989}{1}
% \parsertest{1ex}{4.305542}{1}
% \parsertest{1em}{10.000015}{1}
\parsertest{1bp}{1.003738}{1}
\parsertest{1dd}{1.070007}{1}
\parsertest{1cc}{12.840103}{1}
\parsertest{1sp}{0.000015}{1}
\parsertest{1pc}{12.0}{1}
% these TeX macros must be defined and set, of course!
\count1=43
% this is actually UNSUPPORTED by TeX:
\parsertest[compare with TeX=false,compare with fpu=false]{\count1}{43.0}{0}
%
\newdimen\luamathparse@dimen
\luamathparse@dimen=42pt
\parsertest{1*\luamathparse@dimen}{42.0}{1}
\parsertest{2\luamathparse@dimen}{84.0}{1}
%
\newcount\luamathparse@count
\luamathparse@count=42
\parsertest{1*\luamathparse@count}{42.0}{0}
% this is a BUG in TeX, but works in LUA...:
\parsertest[compare with TeX=false,compare with fpu=false]{0.5\luamathparse@count}{21.0}{0}
%
\setbox0=\hbox{1233}
\parsertest{\wd0}{20.000061}{1}
\parsertest{\ht0}{6.444443}{1}
\parsertest{\dp0}{0.0}{1}
%--------------------------------------------------
% FIXME : these cases are still missing:
% if false then
% -- arrays created via '{}' and indexed with '[]'
% -- strings with "<str>"
% -- 'scalar' function
% -- hex/octal/binary input
% -- tex registers
% -- What happens for undefined functions!? --> return nil and let TeX invoke its parser (no warning!?)
% -- width/height/depth
% end
%--------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% The following tests are just for the TeX part, not for the LUA part.
%
%
\parsertest[output format=float,compare with TeX=false]{4+4}{1Y8.0e+00]}{0}
\begingroup
\pgfmathdeclarefunction{testfct}{0}{\def\pgfmathresult{42.42}}
\parsertest[parser,compare with TeX=false,compare with fpu=false,show error message=false]{testfct}{}{0}
\parsertest[parser,enable TeX fallback]{testfct}{42.42}{0}
\def\macro{1234}
\pgfkeys{/pgf/declare function={res(\x)=\x*\macro;}}
\parsertest[enable TeX fallback=true]{res(1)}{1234.0}{0}
\endgroup
% Check that setseed is communicated to LUA:
\pgfmathsetseed{123}
\parsertest[compare with TeX=false,compare with fpu=false]{rnd}{0.788318}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{rnd}{0.203068}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{rand}{-0.302874}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{rand}{-0.276781}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{random}{0.134639}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{random}{0.375968}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{random(4)}{2.0}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{random(4)}{1.0}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{random(4,10)}{10.0}{0}
\parsertest[compare with TeX=false,compare with fpu=false]{random(4,10)}{8.0}{0}
\begingroup
% Check that 'trig format' is property communicated to LUA and
% implemented correctly:
\parsertest{sin(50)}{0.766044}{0}%
\parsertest{cos(50)}{0.642788}{0}%
\parsertest{tan(50)}{1.191754}{0}%
\parsertest{asin(0.766044)}{49.999961}{0}%
\parsertest{acos(0.642788)}{49.999971}{0}%
\parsertest{atan(1.191754)}{50.00001}{0}%
\parsertest{atan2(-4,3)}{-53.130102}{0}%
\parsertest{cot(50)}{0.8391}{0}%
\parsertest{sec(50)}{1.555724}{0}%
\parsertest{cosec(50)}{1.305407}{0}%
%
\pgfkeys{/pgf/trig format=rad}
\parsertest{sin(0.5)}{0.479426}{0}%
\parsertest{cos(0.5)}{0.877583}{0}%
\parsertest{tan(0.5)}{0.546302}{0}%
\parsertest{asin(0.5)}{0.523599}{0}%
\parsertest{acos(0.5)}{1.047198}{0}%
\parsertest{atan(0.5)}{0.463648}{0}%
\parsertest{atan2(-4,3)}{-0.927295}{0}%
\parsertest{cot(0.5)}{1.830488}{0}%
\parsertest{sec(0.5)}{1.139494}{0}%
\parsertest{cosec(0.5)}{2.08583}{0}%
\endgroup
\begingroup
\pgfkeys{/pgf/declare function={mu1(\x,\i)=\x^\i;}}
\parsertest{mu1(5,2)}{25.0}{0}
% produces something different in TeX :-( See docs in LUA
\parsertest[compare with TeX=false]{mu1(-5,2)}{25.0}{0}
\begingroup
\pgfkeys{/pgf/declare function={mu2=42;}}
\parsertest{mu2}{42.0}{0}
\endgroup
% should have been clean up:
\parsertest[show error message=false,compare with TeX=false,compare with fpu=false]{mu2}{}{0}
% ... but this should NOT have been cleaned up!
\parsertest{mu1(5,2)}{25.0}{0}
\endgroup
% should have been clean up:
\parsertest[show error message=false,compare with TeX=false,compare with fpu=false]{mu1(-5,2)}{}{0}
\def\pgfmathifexpressionTest#1{%
\pgfmathifexpression{1000>999}{%
% ok
\message{PASSED for mathifexpression(1000>999) #1: = '\pgfmathresult'^^J}%
}{%
\message{FAILURE for mathifexpression(1000>999) #1: = '\pgfmathresult'^^J}%
\global\advance\numErrors by1
}%
}
\pgfmathifexpressionTest{basicmath}
\begingroup
\pgfkeys{/pgf/fpu}%
\pgfmathifexpressionTest{fpu}
\endgroup
\begingroup
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathifexpressionTest{fpu output fixed}
\endgroup
\begingroup
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=sci}%
\pgfmathifexpressionTest{fpu output sci}
\endgroup
\begingroup
\pgfkeys{/pgf/luamath/parser}%
\pgfmathifexpressionTest{luamath}
\endgroup
\begingroup
\pgfkeys{/pgf/luamath/parser,/pgf/luamath/output format=float}%
\pgfmathifexpressionTest{luamath output float}
\endgroup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
% NO MORE TEST CASES HERE!
\ifnum\numErrors>0
\PackageError{pgf}{Has \the\numErrors\space FAILURES}{}
\else
\message{All cases PASSED^^J}%
\fi
\end{document}
|