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
|
/*
* Test that variables can only be assigned to a set of allowed values
* and that an error is thrown if such an attempt is made.
*/
/*
* Function that tests if VAR can successfully set to each of the
* values in ALLOWED, but causes an error if set to INVALID.
*
* Returns a list of the assigned values and an empty list if the test
* succeeded.
*/
(test_setter(var, allowed, invalid) :=
block([result:[]],
append(map(lambda([v], var:: v), allowed),
[errcatch(var:: invalid)])),
0);
0;
test_setter('display2d_unicode, [false, true], 99);
[false, true, []];
test_setter('logexpand, [false, true, all], 99);
[false, true, all, []];
test_setter('loadprint, [false, true, 'loadfile, 'autoload], 99);
[false, true, 'loadfile, 'autoload, []];
test_setter('radexpand, [false, true, 'all], 99);
[false, true, all, []];
test_setter('rootsconmode, [false, true, 'all], 99);
[false, true, all, []];
test_setter('triginverses, [false, true, 'all], 99);
[false, true, all, []];
test_setter('scalarmatrixp, [false, true, 'all], 99);
[false, true, all, []];
test_setter('assumescalar, [false, true, 'all], 99);
[false, true, all, []];
test_setter('savedef, [false, true, 'all], 99);
[false, true, all, []];
test_setter('showtime, [false, true, 'all], 99);
[false, true, all, []];
test_setter('tr_warn_fexpr, ['all, 'compile, 'compfile, 'translate], 99);
['all, 'compile, 'compfile, 'translate, []];
test_setter('tr_warn_meval, ['all, 'compile, 'compfile, 'translate], 99);
['all, 'compile, 'compfile, 'translate, []];
test_setter('tr_warn_mode, ['all, 'compile, 'compfile, 'translate], 99);
['all, 'compile, 'compfile, 'translate, []];
test_setter('tr_warn_undeclared, ['all, 'compile, 'compfile, 'translate], 99);
['all, 'compile, 'compfile, 'translate, []];
test_setter('tr_warn_undefined_variable, ['all, 'compile, 'compfile, 'translate], 99);
['all, 'compile, 'compfile, 'translate, []];
(reset(), 0);
0;
|