Permalink
Browse files

[rakudo] add directives to S29-num/ and convert pod to pod6

git-svn-id: http://svn.pugscode.org/pugs@19712 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 983f107 commit 626a59c1c013e11dbc0c4986fb690bffa16e0a57 particle committed Jan 27, 2008
Showing with 136 additions and 120 deletions.
  1. +8 −5 S29-num/abs.t
  2. +41 −39 S29-num/complex.t
  3. +12 −10 S29-num/exp.t
  4. +23 −20 S29-num/int.t
  5. +5 −5 S29-num/log.t
  6. +5 −4 S29-num/pi.t
  7. +17 −16 S29-num/rand.t
  8. +10 −5 S29-num/roots.t
  9. +6 −9 S29-num/rounders.t
  10. +3 −2 S29-num/sign.t
  11. +6 −5 S29-num/sqrt.t
View
@@ -4,29 +4,32 @@ plan 40;
# L<S29/Num/"=item abs">
-#?rakudo skip 'Cannot parse pod'
-{
-=pod
+=begin pod
Basic tests for the abs() builtin
-=cut
-}
+=end pod
for(0, 0.0, 1, 50, 60.0, 99.99) {
is(abs($_), $_, "got the right absolute value for $_");
+#?rakudo skip 'parsefail'
is(WHAT abs($_), WHAT $_, "got the right data type("~WHAT($_)~") of absolute value for $_");
}
for(-1, -50, -60.0, -99.99) {
is(abs($_), -$_, "got the right absolute value for $_");
+#?rakudo skip 'parsefail'
is(WHAT abs($_), WHAT $_, "got the right data type("~WHAT($_)~") of absolute value for $_");
}
for (0, 0.0, 1, 50, 60.0, 99.99) {
+#?rakudo skip 'parsefail'
is(.abs, $_, 'got the right absolute value for $_='~$_);
+#?rakudo skip 'parsefail'
is(WHAT .abs, WHAT $_, 'got the right data type('~WHAT($_)~') of absolute value for $_='~$_);
}
for (-1, -50, -60.0, -99.99) {
+#?rakudo skip 'parsefail'
is(.abs, -$_, 'got the right absolute value for $_='~$_);
+#?rakudo skip 'parsefail'
is(WHAT .abs, WHAT $_, 'got the right data type('~WHAT($_)~') of absolute value for $_='~$_);
}
View
@@ -4,55 +4,57 @@ use Test;
plan 129;
-#?rakudo skip 'Cannot parse pod'
-{
-=pod
+=begin pod
Basic tests functions specific to complex numbers.
L<S29/Num/"=item cis">
-=cut
-}
+=end pod
+
+#?rakudo skip "can't parse complex numbers"
+{
-my $pi = 3.141592653589793238;
+ my $pi = 3.141592653589793238;
-is_approx((cis(0), 1 + 0i), "cis(0) == 1");
-is_approx((cis($pi), -1 + 0i), "cis(pi) == -1");
-is_approx((cis($pi / 2), 1i), "cis(pi/2) == i");
-is_approx((cis(3*$pi / 2),1i), "cis(3pi/2) == i");
+ is_approx((cis(0), 1 + 0i), "cis(0) == 1");
+ is_approx((cis($pi), -1 + 0i), "cis(pi) == -1");
+ is_approx((cis($pi / 2), 1i), "cis(pi/2) == i");
+ is_approx((cis(3*$pi / 2),1i), "cis(3pi/2) == i");
-# L<S29/Num/"=item cis">
-# L<S29/Num/"=item unpolar">
-#
-# Test that 1.unpor == cis
+ # L<S29/Num/"=item cis">
+ # L<S29/Num/"=item unpolar">
+ #
+ # Test that 1.unpor == cis
-for 1..20 -> $i {
- my $angle = 2 * $pi * $i / 20;
- is_approx((cis($i), 1.unpolar($i)), "cis(x) == 1.unpolar(x) No $i");
-}
+ for 1..20 -> $i {
+ my $angle = 2 * $pi * $i / 20;
+ is_approx((cis($i), 1.unpolar($i)), "cis(x) == 1.unpolar(x) No $i");
+ }
-# L<S29/Num/"=item unpolar">
-# L<S29/Num/"=item abs">
-#
-# Test that unpolar() doesn't change the absolute value
-
-my $counter = 1;
-for 1..10 -> $abs {
- for 1..10 -> $a {
- my $angle = 2 * $pi * $i / 10;
- is_approx((abs($abs.unpolar($angle)), $abs ),
- "unpolar doesn't change the absolute value (No $counter)");
- $counter++;
+ # L<S29/Num/"=item unpolar">
+ # L<S29/Num/"=item abs">
+ #
+ # Test that unpolar() doesn't change the absolute value
+
+ my $counter = 1;
+ for 1..10 -> $abs {
+ for 1..10 -> $a {
+ my $angle = 2 * $pi * $i / 10;
+ is_approx((abs($abs.unpolar($angle)), $abs ),
+ "unpolar doesn't change the absolute value (No $counter)");
+ $counter++;
+ }
}
-}
-# L<S29/Num/"=item unpolar">
-#
-# Basic tests for unpolar()
+ # L<S29/Num/"=item unpolar">
+ #
+ # Basic tests for unpolar()
-is_approx((4.unpolar(0), 4), "4.unpolar(0) == 4");
-is_approx((4.unpolar($pi/4), 2 + 2i),"4.unpolar(pi/4) == 2+2i");
-is_approx((4.unpolar($pi/2), 4i), "4.unpolar(pi/2) == 4i");
-is_approx((4.unpolar(3*$pi/4), -2 +2i),"4.unpolar(pi/4) == -2+2i");
-is_approx((4.unpolar($pi), -4), "4.unpolar(pi) == -4");
+ is_approx((4.unpolar(0), 4), "4.unpolar(0) == 4");
+ is_approx((4.unpolar($pi/4), 2 + 2i),"4.unpolar(pi/4) == 2+2i");
+ is_approx((4.unpolar($pi/2), 4i), "4.unpolar(pi/2) == 4i");
+ is_approx((4.unpolar(3*$pi/4), -2 +2i),"4.unpolar(pi/4) == -2+2i");
+ is_approx((4.unpolar($pi), -4), "4.unpolar(pi) == -4");
+}
+#?rakudo emit skip_rest();
View
@@ -4,25 +4,27 @@ plan 44;
# L<S29/Num/"=item exp">
-#?rakudo skip 'Cannot parse pod'
-{
-=pod
+=begin pod
Basic tests for the exp() builtin
-=cut
-}
+=end pod
+#?rakudo 2 skip "is_approx failing"
is_approx((exp(5), 148.4131591025766), 'got the exponent of 5');
is_approx((exp(0), 1), 'exp(0) == 1');
+#?rakudo 2 skip "can't parse complex numbers"
# exp with complex arguments
is_approx((exp(1i*pi), -1), 'exp(i pi) == -1');
is_approx((exp(-1i*pi), -1), 'exp(-i pi) == -1');
-for 1 .. 20 {
- my $arg = 2.0 * pi / $_;
- is_approx((exp(1i * $arg), cos($arg) + 1i * sin($arg)), 'expi == cos + i sin No. ' ~ $_);
- is_approx((exp(1i * $arg) * exp(-1i * $arg), 1), 'exp(ix) * exp(-ix) == 1 No. ' ~ $_);
+#?rakudo skip "can't parse complex numbers"
+{
+ for 1 .. 20 {
+ my $arg = 2.0 * pi / $_;
+ is_approx((exp(1i * $arg), cos($arg) + 1i * sin($arg)), 'expi == cos + i sin No. ' ~ $_);
+ is_approx((exp(1i * $arg) * exp(-1i * $arg), 1), 'exp(ix) * exp(-ix) == 1 No. ' ~ $_);
+ }
}
-
+#?rakudo emit skip_rest "can't parse complex numbers";
View
@@ -6,14 +6,11 @@ plan 58;
# truncate and int() are synonynms.
# Possibly more tests for truncate should be added here, too.
-#?rakudo skip 'Cannot parse pod'
-{
-=pod
+=begin pod
Basic tests for the int() builtin
-=cut
-}
+=end pod
is(int(-1), -1, "int(-1) is -1");
is(int(0), 0, "int(0) is 0");
@@ -49,30 +46,36 @@ is(int('-1.999'), -1, "int('-1.999') is -1");
is(int('0x123'), 0x123, "int('0x123') is 0x123");
is(int('0d456'), 0d456, "int('0d456') is 0d456");
is(int('0o678'), 0o67, "int('0o678') is 0o67");
+#?rakudo: skip 'parsefail'
is(int('3e4d5'), 3e4, "int('3e4d5') is 3e4");
-sub __int( Str $s ) {
- if ($s ~~ rx:Perl5/^(-?\d+)$/) { return $0 };
- if ($s ~~ rx:Perl5/^(-?\d+)\./) { return $0 };
- if ($s ~~ rx:Perl5/^\./) { return 0 };
- return undef;
-};
-
-# Check the defaulting to $_
-
-for(0, 0.0, 1, 50, 60.0, 99.99, 0.4, 0.6,
- -1, -50, -60.0, -99.99
- ) {
- my $int = __int($_);
- is(.int, $int, "integral value for $_ is $int");
- isa_ok(.int, "Int");
+#?rakudo skip 'parsefail'
+{
+ sub __int( Str $s ) {
+ if ($s ~~ rx:Perl5/^(-?\d+)$/) { return $0 };
+ if ($s ~~ rx:Perl5/^(-?\d+)\./) { return $0 };
+ if ($s ~~ rx:Perl5/^\./) { return 0 };
+ return undef;
+ };
+
+ # Check the defaulting to $_
+
+ for(0, 0.0, 1, 50, 60.0, 99.99, 0.4, 0.6,
+ -1, -50, -60.0, -99.99
+ ) {
+ my $int = __int($_);
+ is(.int, $int, "integral value for $_ is $int");
+ isa_ok(.int, "Int");
+ }
}
# Special values
+#?rakudo 4 skip 'parsefail'
is(int(1.9e3), 1900, "int 1.9e3 is 1900");
#?pugs 3 todo 'bug'
is(int(Inf), Inf, "int Inf is Inf");
is(int(-Inf), -Inf, "int -Inf is -Inf");
is(int(NaN), NaN, "int NaN is NaN");
+#?rakudo emit skip_rest 'parsefail';
View
@@ -2,14 +2,11 @@ use v6-alpha;
use Test;
plan 11;
-#?rakudo skip 'Cannot parse pod'
-{
-=pod
+=begin pod
Basic tests for the log() and log10() builtins
-=cut
-}
+=end pod
# L<S29/Num/"=item log">
@@ -28,15 +25,18 @@ is_approx(log10(0.1), -0.9999999999999998, 'got the log10 of 0.1');
# log(exp(i pi)) = i pi log(exp(1)) = i pi
#?pugs 2 todo 'feature'
+#?rakudo 2 skip 'parsefail'
is_approx((log(-1 + 0i,), 0 + 1i * pi), "got the log of -1");
is_approx((log10(-1 + 0i), 0 + 1i * pi), "got the log10 of -1");
# log(exp(1+i pi)) = 1 + i pi
#?pugs 2 todo 'feature'
+#?rakudo 2 skip 'parsefail'
is_approx((log(-exp(1)) + 0i, 1 + 1i * pi), "got the log of -e");
is_approx((log10(-10 + 0i), 1 + 1i * pi), "got the log10 of -10");
#?pugs todo 'feature'
+#?rakudo 3 skip 'parsefail'
is_approx((log((1+1i) / sqrt(2)), 1 + 1i * pi / 4), "got log of exp(i pi/4)");
is_approx((log(1i), 1i * pi / 2), "got the log of i (complex unit)");
#?pugs todo 'feature'
View
@@ -4,18 +4,19 @@ plan 6;
# L<S29/Num/"Num provides a number of constants">
-#?rakudo skip 'Cannot parse pod'
-{
+=begin pod
+
=head1 DESCRIPTION
Basic tests for builtin Num::pi
-=cut
-}
+=end pod
+
# See also: L<"http://theory.cs.iitm.ernet.in/~arvindn/pi/"> :)
my $PI = 3.14159265358979323846264338327950288419716939937510;
+#?rakudo 6 skip 'eval not implemented'
is_approx((eval("Num::pi "), $PI),
"Num::pi");
View
@@ -4,14 +4,11 @@ use Test;
plan 2 + 2*10 + 4;
-#?rakudo skip 'Cannot parse pod'
-{
-=pod
+=begin pod
Basic tests for the rand() builtin
-=cut
-}
+=end pod
# L<S29/Num/"=item rand">
@@ -25,19 +22,23 @@ for 1 .. 10 {
# L<S29/Num/"=item srand">
+#?rakudo skip 'parsefail'
ok(srand(1), 'srand(1) parses');
-sub repeat_rand ($seed) {
- srand($seed);
- for 1..99 { rand(); }
- return rand();
-}
+#?rakudo skip 'parsefail'
+{
+ sub repeat_rand ($seed) {
+ srand($seed);
+ for 1..99 { rand(); }
+ return rand();
+ }
-ok(repeat_rand(314159) == repeat_rand(314159),
- 'srand() provides repeatability for rand()');
+ ok(repeat_rand(314159) == repeat_rand(314159),
+ 'srand() provides repeatability for rand()');
-ok(repeat_rand(0) == repeat_rand(0),
- 'edge case: srand(0) provides repeatability');
+ ok(repeat_rand(0) == repeat_rand(0),
+ 'edge case: srand(0) provides repeatability');
-ok(repeat_rand(0) != repeat_rand(1),
- 'edge case: srand(0) not the same as srand(1)');
+ ok(repeat_rand(0) != repeat_rand(1),
+ 'edge case: srand(0) not the same as srand(1)');
+}
View
@@ -4,16 +4,20 @@ plan 10;
# L<S29/Num/"=item roots">
-sub has_approx($n, @list) {
- for @list -> my $i {
- if approx($i, $n) {
- return 1;
+#?rakudo skip 'parsefail'
+{
+ sub has_approx($n, @list) {
+ for @list -> my $i {
+ if approx($i, $n) {
+ return 1;
+ }
}
+ return undef;
}
- return undef;
}
#?pugs todo 'feature'
+#?rakudo skip 'parsefail'
{
my @l = eval('roots(-1, 2)');
ok(!$!, 'roots($x, $n) compiles');
@@ -23,6 +27,7 @@ sub has_approx($n, @list) {
}
#?pugs todo 'feature'
+#?rakudo skip 'parsefail'
{
my @l = eval('16.roots(4)');
ok(!$!, '$x.roots($n) compiles');
Oops, something went wrong.

0 comments on commit 626a59c

Please sign in to comment.