/*
 * 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;