Skip to content

Commit

Permalink
[v6.d REVIEW] Loosen abs on complex tests
Browse files Browse the repository at this point in the history
- Use is-approx, since we're dealing with floating point math
- Clarify how you get 5e0 from abs(3+4i)

Orig: 2e1428a07
  • Loading branch information
zoffixznet committed Jul 15, 2018
1 parent 2ec8f96 commit bf9171b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions S32-num/complex.t
Expand Up @@ -218,9 +218,11 @@ ok Num(exp i * π) == -1, 'Num(Complex) pays attention to $*TOLERANCE';
is ( 42.5-72.5i).truncate, 42-72i, '.truncate (+r-i), .5r, .5i';
is (-42.5-72.5i).truncate, -42-72i, '.truncate (-r-i), .5r, .5i';

is-deeply abs(3+4i), 5e0, 'abs(3+4i)';
is-deeply abs(i), 1e0, 'abs(i)';
cmp-ok abs(1+i), '==', sqrt(2), 'abs(1+i)';
# absolute of a complex is like applying the Pythagoras theorem to a
# triangle with a re./im. values being sides and the abs being hypotenuse
is-approx abs(3+4i), 5e0, 'abs(3+4i)';
is-approx abs(i), 1e0, 'abs(i)';
is-approx abs(1+i), sqrt(2), 'abs(1+i)';

subtest 'Real ≅ Complex' => {
plan 6;
Expand Down

0 comments on commit bf9171b

Please sign in to comment.