# Test the logical operators.

printf ("Starting the logic tests...\n");

assert = strip (function (t)
{
  if (!test(t))
  {
    message ("...failed.\a");
    exception ();
  }
});

assert (all ((-1 | 0), (0 | .01), ("" | ["x"]), (sqrt(-1) | 0)));
assert (all (test (0|(0,0,1)), !test ((0,0,0)|0.0*(1:3))));
assert ([0,0;1,0]|fill(2,2;0.0));
assert (all (0&1|1, 1|1&0, (1|0&&1), (0|1&&1|0)));
assert ("x" || NULL/2);
assert (NULL || {} || vector () || abs);
assert (
  9 & -3 &&
  2.1 & sqrt(-1) &&
  1 & 3.14 &&
  (0,0,1) & (1:3) &&
  [0,0,1] & sqrt(-1) &&
  [0,0,1] & [0,0,sqrt(-1)] &&
  "x" & "y" &&
  dice("hello") & dice("there") &&
  sqrt
);
assert (all (0<1&0<2, 1&0<1&1, 1&0==0&1));
assert (-1 || 0 && 0 || .01 && "" || ["x"] && sqrt(-1) || 0);
assert (class (0 || 0:2) == "vector");

printf ("...passed.\n");


syntax highlighted by Code2HTML, v. 0.9.1