/* Test askinteger and asksign
 *
 * Note:
 * This test file is intended to be run with `batch_answers_from_file' to true.
 *
 * Sample Usage:
 *
 * maxima --batch-string='batch_answers_from_file:true; batch("tests/rtest_ask1.mac", test);'
 *
 * Note that setting `batch_answers_from_file' to true is not needed when `batch(...,test)'
 * is executed via the `batch-string' command-line option. It is needed if the test is done
 * from within a Maxima session.
 */

(kill(all),0);
0$

/*
(?trace(?\$asksign),0);
0$
*/

/* commit 3137b946 tried to fix *LOCAL-SIGNS* craziness,
 * but screwed up in its own way. Fixed for good this time?
 * Nicked from mailing list circa 2013-08-28
 */
 
integrate(sin(omega*t)*exp(-s*t),t,0,inf), ask_hide_prompt; p;
omega/(s^2+omega^2);

[asksign (foo), sign (foo), sign (foo)], ask_hide_prompt; p;
[pos, pos, pos];

[asksign (foo), sign (foo), sign (foo)], ask_hide_prompt; n;
[neg, neg, neg];

[asksign (foo), sign (foo), sign (foo)], ask_hide_prompt; z;
[zero, zero, zero];

limit((exp(a*x)-1)/(exp(a*x)+1),x,inf), ask_hide_prompt; p;
1;

limit((exp(a*x)-1)/(exp(a*x)+1),x,inf), ask_hide_prompt; n;
-1;

limit((exp(a*x)-1)/(exp(a*x)+1),x,inf), ask_hide_prompt; z;
0;

/* mailing list 2017-11-25: "bug in Laplace transform"
 * root cause is asksign(-a^2) forgot the minus sign,
 * so include some cases to handle that and then the Laplace transform.
 */

asksign (a^2), ask_hide_prompt; z;
zero;

asksign (a^2), ask_hide_prompt; nz;
pos;

asksign (a^3), ask_hide_prompt; p;
pos;

asksign (a^3), ask_hide_prompt; n;
neg;

asksign (a^3), ask_hide_prompt; z;
zero;

asksign (-a^2), ask_hide_prompt; z;
zero;

asksign (-a^2), ask_hide_prompt; nz;
neg;

asksign (-a^3), ask_hide_prompt; p;
neg;

asksign (-a^3), ask_hide_prompt; n;
pos;

asksign (-a^3), ask_hide_prompt; z;
zero;

asksign (a^4), ask_hide_prompt; z;
zero;

asksign (a^4), ask_hide_prompt; nz;
pos;

asksign (a^5), ask_hide_prompt; p;
pos;

asksign (a^5), ask_hide_prompt; n;
neg;

asksign (a^5), ask_hide_prompt; z;
zero;

asksign (-a^4), ask_hide_prompt; z;
zero;

asksign (-a^4), ask_hide_prompt; nz;
neg;

asksign (-a^5), ask_hide_prompt; p;
neg;

asksign (-a^5), ask_hide_prompt; n;
pos;

asksign (-a^5), ask_hide_prompt; z;
zero;

asksign (a*b^2), ask_hide_prompt; p;
pos;

asksign (a*b^2), ask_hide_prompt; n;
neg;

asksign (a*b^2), ask_hide_prompt; z;
zero;

asksign (a*b^3), ask_hide_prompt; p;
pos;

asksign (a*b^3), ask_hide_prompt; n;
neg;

asksign (a*b^3), ask_hide_prompt; z;
zero;

asksign (-a*b^2), ask_hide_prompt; p;
neg;

asksign (-a*b^2), ask_hide_prompt; n;
pos;

asksign (-a*b^2), ask_hide_prompt; z;
zero;

asksign (-a*b^3), ask_hide_prompt; p;
neg;

asksign (-a*b^3), ask_hide_prompt; n;
pos;

asksign (-a*b^3), ask_hide_prompt; z;
zero;

asksign (a*b^4), ask_hide_prompt; p;
pos;

asksign (a*b^4), ask_hide_prompt; n;
neg;

asksign (a*b^4), ask_hide_prompt; z;
zero;

asksign (-a*b^4), ask_hide_prompt; p;
neg;

asksign (-a*b^4), ask_hide_prompt; n;
pos;

asksign (-a*b^4), ask_hide_prompt; z;
zero;

asksign (a^2*b^2), ask_hide_prompt; z;
zero;

asksign (a^2*b^2), ask_hide_prompt; nz;
pos;

asksign (a^2*b^3), ask_hide_prompt; p;
pos;

asksign (a^2*b^3), ask_hide_prompt; n;
neg;

asksign (a^2*b^3), ask_hide_prompt; z;
zero;

asksign (-a^2*b^2), ask_hide_prompt; z;
zero;

asksign (-a^2*b^2), ask_hide_prompt; nz;
neg;

asksign (-a^2*b^3), ask_hide_prompt; p;
neg;

asksign (-a^2*b^3), ask_hide_prompt; n;
pos;

asksign (-a^2*b^3), ask_hide_prompt; z;
zero;

asksign (a^2*b^4), ask_hide_prompt; z;
zero;

asksign (a^2*b^4), ask_hide_prompt; nz;
pos;

asksign (a^2*b^5), ask_hide_prompt; p;
pos;

asksign (a^2*b^5), ask_hide_prompt; n;
neg;

asksign (a^2*b^5), ask_hide_prompt; z;
zero;

asksign (-a^2*b^4), ask_hide_prompt; z;
zero;

asksign (-a^2*b^4), ask_hide_prompt; nz;
neg;

asksign (-a^2*b^5), ask_hide_prompt; p;
neg;

asksign (-a^2*b^5), ask_hide_prompt; n;
pos;

asksign (-a^2*b^5), ask_hide_prompt; z;
zero;

/* here's the Laplace transform that exposed the bug */

laplace (delta (t - x^2), t, s), ask_hide_prompt; z;
1;

laplace (delta (t - x^2), t, s), ask_hide_prompt; nz;
exp(-s*x^2);

/* Test READ and READONLY
   See SF Bug #4677 */

read("Enter the sum of 1+2.");1+2;
3;

readonly("Enter the number 2.");2;
2;
