Permalink
Browse files

[t/spec] Replace references to pi the constant with a local variable.

git-svn-id: http://svn.pugscode.org/pugs@29704 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent e35338c commit 1d1fb57f5cb09243ff93cca4bad5ad77369eb9f7 colomon committed Feb 13, 2010
Showing with 11 additions and 8 deletions.
  1. +11 −8 S32-num/roots.t
View
@@ -97,31 +97,34 @@ sub has_approx($n, @list) {
#?rakudo skip "Should this be == or ~~?"
ok(@l[0] ~~ Inf, 'roots(Inf,1) returns Inf');
}
+
+my $pi = 312689/99532;
+
{
my @l = roots(1i,2);
ok(@l.elems == 2, 'roots(1i,2) returns 2 elements');
- ok(has_approx(exp(5i*pi/4), @l), 'exp(5i*pi/4) is a square root of i');
- ok(has_approx(exp(1i*pi/4), @l), 'exp(1i*pi/4) is a square root of i');
+ ok(has_approx(exp(5i*$pi/4), @l), 'exp(5i*$pi/4) is a square root of i');
+ ok(has_approx(exp(1i*$pi/4), @l), 'exp(1i*$pi/4) is a square root of i');
}
{
my @l = roots(1+1i,2);
ok(@l.elems == 2, 'roots(1+1i,2) returns 2 elements');
- ok(has_approx(exp(log(2)/4 + 1i*pi/8), @l),'exp(log(2)/4 + 1i*pi/8) is a square root of 1+1i');
- ok(has_approx(exp(log(2)/4 + 9i*pi/8), @l),'exp(log(2)/4 + 9i*pi/8) is a square root of 1+1i');
+ ok(has_approx(exp(log(2)/4 + 1i*$pi/8), @l),'exp(log(2)/4 + 1i*$pi/8) is a square root of 1+1i');
+ ok(has_approx(exp(log(2)/4 + 9i*$pi/8), @l),'exp(log(2)/4 + 9i*$pi/8) is a square root of 1+1i');
}
{
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) + 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');
+ 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');
+ 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 1d1fb57

Please sign in to comment.