#! ../mstoical

% Test binary operators

'test load

"Testing binary operators...\n" =

% -----------------
" + \t% Addition\n" =
0 0 + 0 eq ok?
0 1 + 1 eq ok?
1 1 + 2 eq ok?
1 -1 + 0 eq ok?
-1 -1 + -2 eq ok?
1.1 1.3 + 2.4 - abs 1.0e-6 lt ok?

% -----------------
" - \t% Subtraction\n" =
0 0 - 0 eq ok?
0 1 - -1 eq ok?
1 1 - 0 eq ok?
1 -1 - 2 eq ok?
2 1 - 1 eq ok?
3.6 1.2 - 2.4 - abs 1.0e-6 lt ok?

% -----------------
" * \t% Multiplication\n" =
0 0 * 0 eq ok?
0 1 * 0 eq ok?
1 5 * 5 eq ok?
-1 5 * -5 eq ok?
-5 -5 * 25 eq ok?
3.6 1.2 * 4.32 - abs 1.0e-6 lt ok?

% -----------------
" / \t% Division\n" =
0 1 / 0 eq ok?
1 1 / 1 eq ok?
2 -1 / -2 eq ok?
10 5 / 2 eq ok?
-10 -5 / 2 eq ok?
3.6 1.2 / 3.0 - abs 1.0e-6 lt ok?

% -----------------
" mod \t% Integer division remainder\n" =
0 1 mod 0 eq ok?
1 1 mod 0 eq ok?
10 4 mod 2 eq ok?
5.9 3.2 mod 2 eq ok?

% -----------------
" /mod \t% Integer division quotient and remainder\n" =
0 1 /mod 0 eq over 0 eq ok? drop
1 1 /mod 0 eq over 1 eq ok? drop
10 5 /mod 0 eq over 2 eq ok? drop
10 4 /mod 2 eq over 2 eq ok? drop

% -----------------
" lt \t% Is less than\n" =
0 0 lt false eq ok?
0 1 lt true eq ok?
1 5 lt true eq ok?
-5 -1 lt true eq ok?
-1 5 lt true eq ok?
-1.4 3.6 lt true eq ok?

% -----------------
" gt \t% Is greater than\n" =
0 0 gt false eq ok?
1 0 gt true eq ok?
5 1 gt true eq ok?
-1 -5 gt true eq ok?
5 -1 gt true eq ok?
3.6 -1.4 gt true eq ok?

% -----------------
" le \t% Is less than or equal\n" =
0 0 le true eq ok?
0 1 le true eq ok?
1 5 le true eq ok?
5 5 le true eq ok?
-5 -1 le true eq ok?
-5 -5 le true eq ok?
-1.4 3.6 le true eq ok?
-1.4 -1.4 le true eq ok?

% -----------------
" ge \t% Is greater than or equal\n" =
0 0 ge true eq ok?
1 0 ge true eq ok?
5 1 ge true eq ok?
5 5 ge true eq ok?
-1 -5 ge true eq ok?
-1 -1 ge true eq ok?
5 -1 ge true eq ok?
3.6 -1.4 ge true eq ok?
3.6 3.6 ge true eq ok?

% -----------------
" feq \t% Is equal\n" =
0 0 feq true eq ok?
0 1 feq false eq ok?
5 1 feq false eq ok?
-5 -5 feq true eq ok?
-5 -1 feq false eq ok?
1.3 1.3 feq true eq ok?

% -----------------
" fne \t% Is not equal\n" =
0 0 fne false eq ok?
0 1 fne true eq ok?
5 1 fne true eq ok?
-5 -5 fne false eq ok?
-5 -1 fne true eq ok?
1.3 3.5 fne true eq ok?
1.3 1.3 fne false eq ok?
-1.3 3.5 fne true eq ok?

% -----------------
" and \t% Bitwise and\n" =
0 0 and 0 eq ok?
0 1 and 0 eq ok?
2 1 and 0 eq ok?
3 1 and 1 eq ok?

% -----------------
" or \t% Bitwise or\n" =
0 0 or 0 eq ok?
0 1 or 1 eq ok?
2 1 or 3 eq ok?
3 1 or 3 eq ok?

% -----------------
" xor \t% Bitwise exclusive or\n" =
0 0 xor 0 eq ok?
0 1 xor 1 eq ok?
2 1 xor 3 eq ok?
3 1 xor 2 eq ok?

fail @ exit
