Permalink
Browse files

Tests for cube roots() of negative numbers

git-svn-id: http://svn.pugscode.org/pugs@25976 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
leto
leto committed Mar 23, 2009
1 parent 20911d4 commit 025f65e5cdaacffc39412e024ed8ff0e750b3366
Showing with 8 additions and 1 deletion.
  1. +8 −1 S32-num/roots.t
View
@@ -1,6 +1,6 @@
use v6;
use Test;
-plan 40;
+plan 44;
# L<S29/Num/"=item roots">
@@ -112,4 +112,11 @@ sub has_approx($n, @list) {
ok(has_approx(exp(1/3*(log(8) + 2i*pi)),@l), 'exp(1/3*(log(8) + 2i*pi)) is a cube root of 8');
ok(has_approx(exp(1/3*(log(8) + 4i*pi)),@l), 'exp(1/3*(log(8) + 4i*pi)) is a cube root of 8');
}
+{
+ my @l = (-8).roots(3);
+ ok(@l.elems == 3, '(-8).roots(3) returns 3 elements');
+ ok(has_approx(-2,@l), '2 is a cube root of 8');
+ ok(has_approx(exp(1/3*(log(8) + 3i*pi)),@l), 'exp(1/3*(log(8) + 3i*pi)) is a cube root of 8');
+ ok(has_approx(exp(1/3*(log(8) + 5i*pi)),@l), 'exp(1/3*(log(8) + 5i*pi)) is a cube root of 8');
+}

0 comments on commit 025f65e

Please sign in to comment.