0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-07-18 20:46:27 +00:00
org-mode/testing/examples/ob-maxima-test.org
Leo Butler 2ba45fcb78
* lisp/ob-maxima.el: enable use of batch' loader and draw'
* (org-babel-header-args:maxima): Document the two new header
arguments (batch and graphics-pkg) that are specific to ob-maxima.
* (org-babel-maxima--command-arguments-default): A new variable
storing the default command-line argument(s).  This value was
hard-coded in `org-babel-maxima:execute'.
* (org-babel-maxima--graphic-package-options): A new variable that
stores an alist of Maxima graphics packages and the Maxima code to set
up that package.
* (org-babel-maxima--default-epilogue): A new variable that stores an
alist of the clean-up code that is run at end of a `graphical-output'
or `non-graphical-output' source block.
* (org-babel-maxima--output-filter-regexps): A new variable that
stores a list of regexps to identify "bad" output lines to be removed
from Maxima's output.  Source-code comments document each regexp's
purpose.  Two additional regexps have been added: one filters
un-wanted output from `batch' and the other removes empty input lines
that `batch'-ed output may spuriously produce (actual empty input
lines are syntax errors, see the new tests below).
* (org-babel-maxima--output-filter): A new function that takes a
single line of Maxima output.  It returns nil if the line has zero
length or matches a regexp in
`org-babel-maxima--output-filter-regexps'; otherwise, it returns the
line.  This function and regexp replace the hard-coded filter in
`org-babel-execute:maxima'.
* (org-babel-maxima-expand): Prepare the source block for execution,
depending on whether it is producing graphical output or not.  In case
of graphical output, use the `graphics-pkg' header to set the graphics
package and use `org-babel-maxima--graphic-package-options' to set-up
the package.  Grovel the graphics terminal from the output filename.
* (org-babel-execute:maxima): Use the :batch header argument and
`org-babel-maxima--command-arguments-default' to execute the source
block.  Replace the existing, in-line output filter and its regexps
with `org-babel-maxima--output-filter' and
`org-babel-maxima--output-filter-regexps'.

* testing/examples/ob-maxima-test.org: Add test examples.

Include examples of the batch-related tests from
testing/lisp/test-ob-maxima.el.  Provide an example of the
`:graphics-pkg' header argument with the `draw' package.

* testing/lisp/test-ob-maxima.el: Introduce six new, batch-related
test functions.  Each test exercises the :batch header argument.  The
response to unusual inputs is tested (empty strings, strings with just
whitespace, input with the `:lisp' reader, and two syntax-related
errors).

link: https://list.orgmode.org/87cyz1ivzw.fsf@t14.reltub.ca/
2023-10-04 11:27:46 +03:00

3.2 KiB

a collection of examples for ob-maxima tests

Simple tests

print(s);

Pass a string

print(diff(fun, x, q))$

Graphic output

Graphic output

plot2d(sin(a*x), [x, 0, 2*%pi])$
plot3d (2^(-u^2 + v^2), [u, -3, 3], [v, -2, 2])$

Use the draw package

This test exercises the :graphics-pkg header argument.

draw2d(explicit(cos(a*x), x, -%pi, %pi))$

Output to a file

Output to a file

for i:1 thru 10 do print(i)$

List input

Simple list as an input

print(a)$
print(a+1);

Table input

1.0
2.0
1.0 2.0
print(s+1.0);
print(s+1.0);

Matrix

1.0 1.0
ms: apply(matrix, s);
print(ms);

Construct a table from the output

with_stdout("/dev/null", load(numericalio))$
m: genmatrix (lambda([i,j], i+j-1), 3, 3)$
write_data(m, "/dev/stdout")$

LaTeX output

assume(x>0);
tex(ratsimp(diff(%e^(a*x), x)));

$$a\,e^{a\,x}$$

Batch

Exercise the :batch header argument. These tests are also defined in testing/lisp/test-ob-maxima.el. The test name is name of the ert test.

(assume(z>0),
integrate(exp(-t)*t^z, t, 0, inf));
(assume(z>0),
integrate(exp(-t)*t^z, t, 0, inf));
:lisp #$(assume(z>0),integrate(exp(-t)*t^z, t, 0, inf));#$
"";
" ";
;
x: