/* Make sure array initalizers work as expected */

void check (poly value, poly correct)
{
    if (is_number (value) && !is_rational (value))
    {
	real	error = abs (value - correct);
	if (error < abs(value) / 1e7)
	    return;
    }
    if (value != correct)
	abort ("check failed (was %v, should be %v)", value, correct);
}

check (([10]) { 1, 2, ... }[9], 2);
check (([*,*]) { { 1, 2, ...}, { 3, 4, 5, 6}} [0,3], 2);
check (([*,*,*]) { { { 1, 2, 3 } ... }, { { 4, 5, 6}, {7, 8, 9}, {10, 11, 12}}}[0,1,2], 3);
check (([10]) { [i] = i ** 2 + 1 }[9], 82);

/* These should all generate compile errors, but shouldn't crash */
file save_stderr = stderr;
stderr = File::open("/dev/null", "w");
([*,*]) { { [i] = i ** 2 + 1 }, { 4, 5, 6, 7, 8 }};
([*]) { 1 ... };
([*,*]) {1};
int[*,*] x = {1};
int[] x = {{1},2};
stderr = save_stderr;

exit(0);
