From 6b575cafef8e1ecc16a247f81304868cdb04df91 Mon Sep 17 00:00:00 2001 From: Robert Dodier Date: Sun, 17 Nov 2024 20:54:31 -0800 Subject: [PATCH] rtest_unit.mac: enclose input expressions in calls to TOPLEVEL-MACSYMA-EVAL in an effort to ensure that results are the same as if typed in at the console input prompt, since TOPLEVEL-MACSYMA-EVAL is applied to user inputs, and the unit package implements its built-in conversion functions via TOPLEVEL-MACSYMA-EVAL. There are fewer test case failures, with this commit, but there are still a number of failures. --- share/contrib/unit/rtest_unit.mac | 129 ++++++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 55 deletions(-) diff --git a/share/contrib/unit/rtest_unit.mac b/share/contrib/unit/rtest_unit.mac index 4a3129ad6..1f62f16ae 100644 --- a/share/contrib/unit/rtest_unit.mac +++ b/share/contrib/unit/rtest_unit.mac @@ -3,162 +3,181 @@ (if not ?boundp ('globalbaseunitlisting) then load ("unit.mac"), 0); 0; -N; -kg*m/s^2; - -dyn; +/* Evaluate all test inputs via TOPLEVEL-MACSYMA-EVAL, since the unit package + * redefines that function to call the pre- and post-processing functions, + * which produce the results that one would see if the input were entered + * at the console input prompt. The code for processing test cases + * (TEST-BATCH in src/mload.lisp) calls MEVAL*, not TOPLEVEL-MACSYMA-EVAL, + * so it misses the pre- and post-evaluation functions, and so the test + * outputs don't come out the same as if they were entered at the input prompt. + * + * I'm leaning towards thinking the pre- and post-evaluation functions + * should be called somehow from MEVAL, since as it stands, working with units + * within functions won't produce the same results as console inputs, since only + * MEVAL is called within functions and not TOPLEVEL-MACSYMA-EVAL (nor MEVAL* + * for that matter). Be that as it may, I will let it stand and work around + * the issue with explicit calls to TOPLEVEL-MACSYMA-EVAL here. + */ + +?toplevel\-macsyma\-eval (N); +kg*m/s^2; + +?toplevel\-macsyma\-eval (dyn); ?rat(1, 100000)*kg*m/s^2; -g; +?toplevel\-macsyma\-eval (g); ?rat(1, 1000)*kg; -centigram*inch/minutes^2; +?toplevel\-macsyma\-eval (centigram*inch/minutes^2); ?rat(127, 1800000000000)*kg*m/s^2; setunits([centigram,inch,minute]); done; -N; +?toplevel\-macsyma\-eval (N); ?rat(1800000000000, 127)*%in*cg/%min^2; -dyn; +?toplevel\-macsyma\-eval (dyn); ?rat(18000000, 127)*%in*cg/%min^2; -g; +?toplevel\-macsyma\-eval (g); 100*cg; -centigram*inch/minutes^2; +?toplevel\-macsyma\-eval (centigram*inch/minutes^2); %in*cg/%min^2; setunits([kg,m,s]); done; -centigram*inch/minutes^2; +?toplevel\-macsyma\-eval (centigram*inch/minutes^2); ?rat(127, 1800000000000)*kg*m/s^2; setunits(N); done; -N; +?toplevel\-macsyma\-eval (N); N; -dyn; +?toplevel\-macsyma\-eval (dyn); ?rat(1, 100000)*N; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); N; -centigram*inch/minutes^2; +?toplevel\-macsyma\-eval (centigram*inch/minutes^2); ?rat(127, 1800000000000)*N; setunits(dyn); done; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); 100000*dyn; -centigram*inch/minutes^2; +?toplevel\-macsyma\-eval (centigram*inch/minutes^2); ?rat(127, 18000000)*dyn; uforget(dyn); false; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); kg*m/s^2; -centigram*inch/minutes^2; +?toplevel\-macsyma\-eval (centigram*inch/minutes^2); ?rat(127, 1800000000000)*kg*m/s^2; setunits([centigram,inch,minute]); done; -centigram*inch/minutes^2; +?toplevel\-macsyma\-eval (centigram*inch/minutes^2); %in*cg/%min^2; uforget([cg,%in,%min]); [false, false, false]; -centigram*inch/minutes^2; +?toplevel\-macsyma\-eval (centigram*inch/minutes^2); ?rat(127, 1800000000000)*kg*m/s^2; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); kg*m/s^2; -convert(kg*m/s^2,[g,km,s]); +?toplevel\-macsyma\-eval (convert(kg*m/s^2,[g,km,s])); g*km/s^2; -convert(kg*m/s^2,[g,inch,minute]); +?toplevel\-macsyma\-eval (convert(kg*m/s^2,[g,inch,minute])); ?rat(18000000000, 127)*%in*g/%min^2; -convert(kg*m/s^2,[N]); +?toplevel\-macsyma\-eval (convert(kg*m/s^2,[N])); N; -convert(kg*m^2/s^2,[N]); +?toplevel\-macsyma\-eval (convert(kg*m^2/s^2,[N])); m*N; setunits([N,J]); done; -convert(kg*m^2/s^2,[N]); +?toplevel\-macsyma\-eval (convert(kg*m^2/s^2,[N])); m*N; -convert(kg*m^2/s^2,[N,inch]); +?toplevel\-macsyma\-eval (convert(kg*m^2/s^2,[N,inch])); ?rat(5000, 127)*%in*N; -convert(kg*m^2/s^2,[J]); +?toplevel\-macsyma\-eval (convert(kg*m^2/s^2,[J])); J; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); J; setunits([g,inch,s]); done; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); N; uforget(N); false; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); ?rat(5000000, 127)*%in*g/s^2; -convert(kg*m/s^2,[g,inch,s]); +?toplevel\-macsyma\-eval (convert(kg*m/s^2,[g,inch,s])); ?rat(5000000, 127)*%in*g/s^2; +uforget (%in); +false; + /* omit examples for usersetunits, since that's hard to test */ setunits([N, J]); done; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); N; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); J; setunits([dyn,eV]); done; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); 100000*dyn; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); 6241509596477042688*eV; -kg*m^3/s^2; +?toplevel\-macsyma\-eval (kg*m^3/s^2); 6241509596477042688*eV*m; -kg*m*km/s^2; +?toplevel\-macsyma\-eval (kg*m*km/s^2); 6241509596477042688000*eV; uforget([dyn,eV]); [false, false]; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); N; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); J; dontusedimension(N); @@ -167,28 +186,28 @@ dontusedimension(N); dontusedimension(J); [%energy, %force]; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); kg*m/s^2; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); kg*m^2/s^2; setunits([dyn,eV]); done; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); kg*m/s^2; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); kg*m^2/s^2; uforget([dyn,eV]); [false, false]; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); kg*m/s^2; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); kg*m^2/s^2; usedimension(N); @@ -197,28 +216,28 @@ true; usedimension(J); true; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); kg*m/s^2; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); kg*m^2/s^2; setunits([dyn,eV]); done; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); 100000*dyn; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); 6241509596477042688*eV; uforget([dyn,eV]); [false, false]; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); N; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); J; kill(usersetunits); @@ -227,9 +246,9 @@ done; uforget([dyn,eV]); [false, false]; -kg*m/s^2; +?toplevel\-macsyma\-eval (kg*m/s^2); kg*m/s^2; -kg*m^2/s^2; +?toplevel\-macsyma\-eval (kg*m^2/s^2); kg*m^2/s^2; -- 2.11.4.GIT