#! ../.stoical

% Test unary operators

'test load

"Testing unary operators...\n" =

% -----------------
" 1+ \t% Increment\n" =
0 1+ 1 eq ok?
1 1+ 2 eq ok?
-1 1+ 0 eq ok?
1.5 1+ 2.5 eq ok?
999998.99 1+ 999999.99 eq ok?
% ( 's 1+ ) should fail with 'type mismatch' error

% -----------------
" 1- \t% Decrement\n" =
0 1- -1 eq ok?
1 1- 0 eq ok?
-1 1- -2 eq ok?
1.5 1- 0.5 eq ok?
999998.99 1- 999997.99 eq ok?

% -----------------
" int \t% Floor a float to integer\n" =
0 int 0 eq ok?
1 int 1 eq ok?
0.3 int 0 eq ok?
0.5 int 0 eq ok?
1.1 int 1 eq ok?
1.5 int 1 eq ok?
-1.5 int -1 eq ok?
-0.3 int 0 eq ok?

% -----------------
" abs \t% Absolute value\n" =
0 abs 0 eq ok?
-0 abs 0 eq ok?
-1 abs 1 eq ok?
-1.5 abs 1.5 eq ok?

% -----------------
" bool \t% Convert to true/false\n" =
0 bool false eq ok?
1 bool true eq ok?
-1 bool true eq ok?
3 bool true eq ok?
-3 bool true eq ok?

% -----------------
" not \t% Bitwise not\n" =
false not true eq ok?
true not false eq ok?
0 not -1 eq ok?
1 not -2 eq ok?
-1 not 0 eq ok?
3 not -4 eq ok?
-3 not 2 eq ok?
-1.3 not 0 eq ok?
-3.3 not 2 eq ok?

% -----------------
" eqz \t% Is equal to 0\n" =
0 eqz true eq ok?
1 eqz false eq ok?
-1 eqz false eq ok?
1.5 eqz false eq ok?
false eqz true eq ok?
true eqz false eq ok?

% -----------------
" ltz \t% Is less than 0\n" =
0 ltz false eq ok?
-1 ltz true eq ok?
-1.5 ltz true eq ok?
1 ltz false eq ok?
1.5 ltz false eq ok?
false ltz false eq ok?
true ltz true eq ok?

fail @ exit
