diff options
author | Karl Berry <karl@freefriends.org> | 2015-08-08 22:54:29 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-08-08 22:54:29 +0000 |
commit | 531d43fafa269c546d587eaca6cd14adcd11914f (patch) | |
tree | 1883933af984c60254e6d9d1bd955a76748cb827 /Master/texmf-dist/source/generic | |
parent | 877e963d44f039783cb9227d90c911866c780961 (diff) |
pgf (8aug15)
git-svn-id: svn://tug.org/texlive/trunk@38079 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/generic')
4 files changed, 605 insertions, 63 deletions
diff --git a/Master/texmf-dist/source/generic/pgf/c/graphdrawing/pgf/gd/interface/c/InterfaceFromC.c b/Master/texmf-dist/source/generic/pgf/c/graphdrawing/pgf/gd/interface/c/InterfaceFromC.c index 8a49947b950..b5606f2f397 100644 --- a/Master/texmf-dist/source/generic/pgf/c/graphdrawing/pgf/gd/interface/c/InterfaceFromC.c +++ b/Master/texmf-dist/source/generic/pgf/c/graphdrawing/pgf/gd/interface/c/InterfaceFromC.c @@ -10,6 +10,8 @@ #include <string.h> +// Remove once Lua Link Bug is fixed: +// // The following is a hack to avoid a problem with the Lua lib being linked twice. // When this happens, two version of "dummynode" exist in Lua and we must ensure that // we never create a table using such a dummynode while using a second lib. @@ -973,7 +975,7 @@ void pgfgd_declare(struct lua_State* state, pgfgd_Declaration* d) if (d && d->key) { int tos = lua_gettop(state); - lua_gc(state, LUA_GCSTOP, 0); // BUG: Remove once linking against dynamic Lua lib works! + lua_gc(state, LUA_GCSTOP, 0); // Remove once Lua Link Bug is fixed // Find declare function: lua_getglobal(state, "require"); @@ -1067,7 +1069,7 @@ void pgfgd_declare(struct lua_State* state, pgfgd_Declaration* d) // Cleanup: lua_settop(state, tos); - lua_gc(state, LUA_GCRESTART, 0); + lua_gc(state, LUA_GCRESTART, 0); // Remove once Lua Link Bug is fixed } } diff --git a/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex index 0497f0d095b..ecae8941fe1 100644 --- a/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex +++ b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/pgfmathtestsuite.tex @@ -1,3 +1,10 @@ +% FIXME: this class is MESSY. +% +% rewrite with proper assertions ... it goes back to a time where I +% merely wanted to inspect the results! +% +% --> see 'assertEquals' in this file +% \documentclass[a4paper]{article} \usepackage[intlimits]{amsmath} @@ -23,6 +30,8 @@ } \makeatother +\pgfmathfloatcreate{1}{5.0}{-4} +\let\THRESH=\pgfmathresult \parindent=0pt @@ -1108,67 +1117,148 @@ } { -\testsection{Testing the FPU library (and math parser)} -\pgfkeys{/pgf/fpu} -% #1 : expression -% #2 : the reference -\def\pgfmathfloattest#1#2{% - \pgfmathfloatparsenumber{#2}% - \let\reference=\pgfmathresult - \message{parsing expression #1...}% - \pgfmathparse{#1}% - \let\argumenta=\pgfmathresult - \let\resultfloat=\pgfmathresult - \pgfmathfloattosci\pgfmathresult - \let\result=\pgfmathresult - \pgfmathfloatrelerror\resultfloat\reference - \pgfmathfloattosci\pgfmathresult - \[ #1 = \result \quad[= \resultfloat] \quad (\text{error/r to }#2 = \pgfmathresult)\] -}% -%\tracingmacros=2\tracingcommands=2 + % #1 : expression + % #2 : the reference + \def\assertEquals#1#2{% + \pgfmathfloatparsenumber{#2}% + \let\reference=\pgfmathresult + \message{parsing expression #1...}% + \pgfmathparse{#1}% + \pgfmathfloatparsenumber{\pgfmathresult}% + \let\argumenta=\pgfmathresult + \let\resultfloat=\pgfmathresult + \pgfmathfloattosci\pgfmathresult + \let\result=\pgfmathresult + \pgfmathfloatrelerror\resultfloat\reference + \let\actualerror=\pgfmathresult + \pgfmathfloatgreaterthan{\pgfmathresult}{\THRESH}% + \ifpgfmathfloatcomparison + \begingroup + \pgfkeys{/pgf/fpu=false}% + \pgfmathparse{#1}% + \global\let\actualBasic=\pgfmathresult + \endgroup + \PackageError{pgf-fpu}{Got error: expected #1=#2, but was \result\space (error \actualerror; basic level returns \actualBasic)}{}% + \fi + \pgfmathfloattosci\actualerror + \[ #1 = \result \quad[= \resultfloat] \quad (\text{error/r to }#2 = \pgfmathresult)\] + }% + \def\mathparserTestCases{% + \assertEquals{1+1}{2} + \assertEquals{1234567*4}{4938268} + \assertEquals{exp(200)}{7.22597376812575e+86} + \assertEquals{rad(360)}{6.28318530717959} + \assertEquals{rad(180)}{3.14159265358979} + \assertEquals{deg(2*pi)}{360} + \assertEquals{deg(pi)}{180} + \assertEquals{ln(1)}{0} + \assertEquals{round(1.5)}{2} + \assertEquals{round(-1.5)}{-2} + \assertEquals{- (1.5)}{-1.5} + \assertEquals{(1e4 - 1e3) * 1e5}{900000000.0} + \assertEquals{4^2}{16} + \assertEquals{4^3}{64} + \assertEquals{4^-3}{0.015625} + \assertEquals{4^-6}{0.000244140625} + \assertEquals{111^4}{151807041} + \assertEquals{8^10}{1073741824} + \assertEquals{3^1.5}{5.19615242270663} + \assertEquals{16^5.5}{4194304} + \assertEquals{15^-0.25}{0.508132748154615} + \assertEquals{sec(45)}{1.4142136e+00} + \assertEquals{cot(30)}{1.7320508e+00} + \assertEquals{asin(7.0710678e-01)}{45} + \assertEquals{acos(8.6602540e-01)}{30} + \assertEquals{atan(5.7735027e-01)}{30} + \assertEquals{atan(16000)}{89.9964} + \assertEquals{atan(1e6)}{8.9999943e+01} + \assertEquals{atan(-1e6)}{-8.9999943e+01} + \assertEquals{-12^2}{-144}% + \assertEquals{0-12^2}{-144}% + \assertEquals{-(12)^2}{-144}% + \assertEquals{exp(-12^2)}{2.8946e-63}% + \assertEquals{round(98.8)}{99}% + \assertEquals{-pi}{-3.14159265358979}% + \assertEquals{2*(-pi)}{-6.28318530717959}% + \assertEquals{2*(-3)}{-6}% + \assertEquals{veclen(1,1)}{1.414213562373095}% + \assertEquals{veclen(1e5,6e5)}{6.082762530298220e+05}% + \assertEquals{cosh(5)}{74.20994852478784}% + \assertEquals{sinh(0.6)}{0.636653582148241}% + \assertEquals{tanh(0.6)}{0.537049566998035}% + + {\pgfkeys{/pgf/trig format=rad} + \assertEquals{atan2(4,5)}{0.674740942223553}% + \assertEquals{atan2(-4,5)}{-0.674740942223553}% + \assertEquals{atan2(4,-5)}{2.46685171136624}% + \assertEquals{atan2(-4,-5)}{-2.46685171136624}% + % + \assertEquals{atan2(5,4)}{0.89605538457134}% + \assertEquals{atan2(-5,4)}{-0.89605538457134}% + \assertEquals{atan2(5,-4)}{2.24553726901845}% + \assertEquals{atan2(-5,-4)}{-2.24553726901845}% + % + \assertEquals{atan2(4e-5,5)}{0}% + \assertEquals{atan2(4e-5,-5)}{3.1415126535899}% + } + % \assertEquals{ceil(1.5)}{2} + } + + + { + \testsection{Testing the FPU library (and math parser)} + \pgfkeys{/pgf/fpu} + %\tracingmacros=2\tracingcommands=2 + \mathparserTestCases + } + + { + \def\mathparserTestCases{% + \assertEquals{sin(90)}{1.0}% + \assertEquals{cos(90)}{0.0}% + \assertEquals{tan(45)}{1.0}% + \assertEquals{sec(45)}{1.41429}% + \assertEquals{cosec(30)}{2.0}% + \assertEquals{cot(15)}{3.73215}% + \assertEquals{asin(0.7071)}{44.99945}% + \assertEquals{acos(0.5)}{60}% + \assertEquals{atan(1)}{45}% + \assertEquals{atan(16001)}{90}% + \assertEquals{atan(-16001)}{-90}% + %\assertEquals{atan2(-4,3)}{-53.13011}% + }% + \testsection{Testing trig format=deg, basic layer (selected examples)} + %\tracingmacros=2\tracingcommands=2 + \mathparserTestCases + + \testsection{Testing trig format=deg, FPU (selected examples)} + \pgfkeys{/pgf/fpu} + \mathparserTestCases + } - \pgfmathfloattest{1+1}{2} - \pgfmathfloattest{1234567*4}{4938268} - \pgfmathfloattest{exp(200)}{7.22597376812575e+86} - \pgfmathfloattest{rad(360)}{6.28318530717959} - \pgfmathfloattest{rad(180)}{3.14159265358979} - \pgfmathfloattest{deg(2*pi)}{360} - \pgfmathfloattest{deg(pi)}{180} - \pgfmathfloattest{ln(1)}{0} - \pgfmathfloattest{round(1.5)}{2} - \pgfmathfloattest{round(-1.5)}{-2} - \pgfmathfloattest{- (1.5)}{-1.5} - \pgfmathfloattest{(1e4 - 1e3) * 1e5}{900000000.0} - \pgfmathfloattest{4^2}{16} - \pgfmathfloattest{4^3}{64} - \pgfmathfloattest{4^-3}{0.015625} - \pgfmathfloattest{4^-6}{0.000244140625} - \pgfmathfloattest{111^4}{151807041} - \pgfmathfloattest{8^10}{1073741824} - \pgfmathfloattest{3^1.5}{5.19615242270663} - \pgfmathfloattest{16^5.5}{4194304} - \pgfmathfloattest{15^-0.25}{0.508132748154615} - \pgfmathfloattest{sec(45)}{1.4142136e+00} - \pgfmathfloattest{cot(30)}{1.7320508e+00} - \pgfmathfloattest{asin(7.0710678e-01)}{45} - \pgfmathfloattest{acos(8.6602540e-01)}{30} - \pgfmathfloattest{atan(5.7735027e-01)}{30} - \pgfmathfloattest{atan(16000)}{89.9964} - \pgfmathfloattest{atan(1e6)}{8.9999943e+01} - \pgfmathfloattest{atan(-1e6)}{-8.9999943e+01} - \pgfmathfloattest{-12^2}{-144}% - \pgfmathfloattest{0-12^2}{-144}% - \pgfmathfloattest{-(12)^2}{-144}% - \pgfmathfloattest{exp(-12^2)}{2.8946e-63}% - \pgfmathfloattest{round(98.8)}{99}% - \pgfmathfloattest{-pi}{-3.14159265358979}% - \pgfmathfloattest{2*(-pi)}{-6.28318530717959}% - \pgfmathfloattest{2*(-3)}{-6}% - \pgfmathfloattest{veclen(1,1)}{1.414213562373095}% - \pgfmathfloattest{veclen(1e5,6e5)}{6.082762530298220e+05}% - \pgfmathfloattest{cosh(5)}{74.20994852478784}% - \pgfmathfloattest{sinh(0.6)}{0.636653582148241}% - \pgfmathfloattest{tanh(0.6)}{0.537049566998035}% -% \pgfmathfloattest{ceil(1.5)}{2} + { + \pgfkeys{/pgf/trig format=rad} + \def\mathparserTestCases{% + \assertEquals{sin(pi/2)}{1.0}% + \assertEquals{cos(pi/2)}{0.0}% + \assertEquals{tan(pi/4)}{1.0}% + \assertEquals{sec(pi/4)}{1.41429}% + \assertEquals{cosec(rad(30))}{2.0}% + \assertEquals{cot(rad(15))}{3.73215}% + \assertEquals{asin(0.7071)}{0.785388564086562}% 44.99945}% + \assertEquals{acos(0.5)}{1.0471975511966}% + \assertEquals{atan(1)}{0.785398163397448}%45}% + \assertEquals{atan(16001)}{1.570796326794}% + \assertEquals{atan(-16001)}{-1.570796326794}% + %\assertEquals{atan2(-4,3)}{-53.13011}% + }% + \testsection{Testing trig format=rad, basic layer (selected examples)} + %\tracingmacros=2\tracingcommands=2 + \mathparserTestCases + + \testsection{Testing trig format=rad, FPU (selected examples)} + \pgfkeys{/pgf/fpu} + \mathparserTestCases + } } \end{document} diff --git a/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.pdf b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.pdf Binary files differnew file mode 100644 index 00000000000..5dfdae7d854 --- /dev/null +++ b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.pdf diff --git a/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.tex b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.tex new file mode 100644 index 00000000000..62ede4b9647 --- /dev/null +++ b/Master/texmf-dist/source/generic/pgf/testsuite/mathtest/unittest_luamathparser.tex @@ -0,0 +1,450 @@ +\documentclass{article} + +\makeatletter +\usepackage{pgf} +\usepgflibrary{luamath} + +\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 +\pgfkeys{ + /ut/compare with TeX/.is if=comparewithtex, + /ut/compare with TeX=true, + /ut/.search also={/pgf/luamath}, + /pgf/luamath/show error message=true, + /pgf/luamath/enable TeX fallback=false, +} + +\newcount\numErrors +\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 + \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 + \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{-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{ceil(0.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{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.6)}{0.0}{0} +\parsertest{floor(-0.6)}{-1.0}{0} +\parsertest{frac(1.1)}{0.1}{0} +\parsertest{frac(-1.1)}{0.1}{0} +\parsertest{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{iseven(2)}{1.0}{0} +\parsertest{isodd(1)}{1.0}{0} +\parsertest{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{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{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{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]{\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]{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,show error message=false]{testfct}{}{0} +\parsertest[parser,enable TeX fallback]{testfct}{42.42}{0} +\endgroup + +% Check that setseed is communicated to LUA: +\pgfmathsetseed{123} +\parsertest[compare with TeX=false]{rnd}{0.788318}{0} +\parsertest[compare with TeX=false]{rnd}{0.203068}{0} +\parsertest[compare with TeX=false]{rand}{-0.302874}{0} +\parsertest[compare with TeX=false]{rand}{-0.276781}{0} +\parsertest[compare with TeX=false]{random}{0.134639}{0} +\parsertest[compare with TeX=false]{random}{0.375968}{0} +\parsertest[compare with TeX=false]{random(4)}{2.0}{0} +\parsertest[compare with TeX=false]{random(4)}{1.0}{0} +\parsertest[compare with TeX=false]{random(4,10)}{10.0}{0} +\parsertest[compare with TeX=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]{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]{mu1(-5,2)}{}{0} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%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} |