Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 89 lines (70 sloc) 2.58 kB
58135b3 [t/spec] changed 'use v6-alpha;' to 'use v6;'
moritz authored
1 use v6;
ad1b86b [t] Test suite refactoring.
cosimo authored
2
3 use Test;
4
6512730 [t/spec] test for Complex.re and .im
moritz authored
5 plan 140;
ad1b86b [t] Test suite refactoring.
cosimo authored
6
6512730 [t/spec] test for Complex.re and .im
moritz authored
7 # Basic tests functions specific to complex numbers.
ad1b86b [t] Test suite refactoring.
cosimo authored
8
4e820b4 [t/spec] more smartlink fixes
moritz authored
9 # L<S32::Numeric/Complex/=item re>
10 # L<S32::Numeric/Complex/=item im>
ad1b86b [t] Test suite refactoring.
cosimo authored
11
6512730 [t/spec] test for Complex.re and .im
moritz authored
12 {
13 is (1 + 2i).re, 1, 'Complex.re works';
14 is (1 + 2i).im, 2, 'Complex.im works';
15 }
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
16
d154816 [t/spec] more smartlink fixing
moritz authored
17 # L<S32::Numeric/Num/=item cis>
5fe1b88 S29-num/complex.t: Update #?rakudo fudging.
pmichaud authored
18 my $pi = 3.141592653589793238;
ad1b86b [t] Test suite refactoring.
cosimo authored
19
5fe1b88 S29-num/complex.t: Update #?rakudo fudging.
pmichaud authored
20 {
4bb1f86 [spec] complex.t: invalid uses of is_approx()
moritz authored
21 is_approx(cis(0), 1 + 0i, "cis(0) == 1");
22 is_approx(cis($pi), -1 + 0i, "cis(pi) == -1");
23 is_approx(cis($pi / 2), 1i, "cis(pi/2) == i");
26eada7 [spec] S29-num/complex.t: fixed two tests
moritz authored
24 is_approx(cis(3*$pi / 2),-1i, "cis(3pi/2) == -i");
5fe1b88 S29-num/complex.t: Update #?rakudo fudging.
pmichaud authored
25 }
ad1b86b [t] Test suite refactoring.
cosimo authored
26
576906b [t] added named arg tests to trig and num functions
frew authored
27 #?rakudo skip 'named args'
28 {
29 is_approx(cis(:angle(0)), 1 + 0i, "cis(:angle(0)) == 1");
30 is_approx(cis(:angle($pi)), -1 + 0i, "cis(:angle(pi)) == -1");
31 is_approx(cis(:angle($pi / 2)), 1i, "cis(:angle(pi/2)) == i");
32 is_approx(cis(:angle(3*$pi / 2)),-1i, "cis(:angle(3pi/2)) == -i");
33 }
34
d154816 [t/spec] more smartlink fixing
moritz authored
35 # Test that 1.unpolar == cis
36 # L<S32::Numeric/Num/=item cis>
37 # L<S32::Numeric/Num/=item unpolar>
5fe1b88 S29-num/complex.t: Update #?rakudo fudging.
pmichaud authored
38
39 {
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
40 for 1..20 -> $i {
41 my $angle = 2 * $pi * $i / 20;
4bb1f86 [spec] complex.t: invalid uses of is_approx()
moritz authored
42 is_approx(cis($i), 1.unpolar($i), "cis(x) == 1.unpolar(x) No $i");
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
43 }
448375e [spec] finer graded fudging of complex.t
moritz authored
44 }
ad1b86b [t] Test suite refactoring.
cosimo authored
45
d154816 [t/spec] more smartlink fixing
moritz authored
46 # L<S32::Numeric/Num/=item abs>
47 # L<S32::Numeric/Num/=item unpolar>
448375e [spec] finer graded fudging of complex.t
moritz authored
48 #
49 # Test that unpolar() doesn't change the absolute value
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
50
448375e [spec] finer graded fudging of complex.t
moritz authored
51 {
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
52 my $counter = 1;
53 for 1..10 -> $abs {
54 for 1..10 -> $a {
72b072b S29-num/complex.t: update #?rakudo skip markers for new passing tests
pmichaud authored
55 my $angle = 2 * $pi * $a / 10;
56 is_approx(abs($abs.unpolar($angle)), $abs,
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
57 "unpolar doesn't change the absolute value (No $counter)");
58 $counter++;
59 }
ad1b86b [t] Test suite refactoring.
cosimo authored
60 }
5fe1b88 S29-num/complex.t: Update #?rakudo fudging.
pmichaud authored
61 }
ad1b86b [t] Test suite refactoring.
cosimo authored
62
d154816 [t/spec] more smartlink fixing
moritz authored
63 # L<S32::Numeric/Num/=item unpolar>
576906b [t] added named arg tests to trig and num functions
frew authored
64 #?rakudo skip 'named args'
65 {
66 # Basic tests for unpolar()
67 my $s = 2 * sqrt(2);
68
69 is_approx(unpolar(:mag(4), 0), 4, "unpolar(:mag(4), 0) == 4");
70 is_approx(unpolar(:mag(4), $pi/4), $s + ($s)i ,"unpolar(:mag(4), pi/4) == 2+2i");
71 is_approx(unpolar(:mag(4), $pi/2), 4i, "unpolar(:mag(4), pi/2) == 4i");
72 is_approx(unpolar(:mag(4), 3*$pi/4), -$s + ($s)i,"unpolar(:mag(4), pi/4) == -2+2i");
73 is_approx(unpolar(:mag(4), $pi), -4, "unpolar(:mag(4), pi) == -4");
74 }
75
5fe1b88 S29-num/complex.t: Update #?rakudo fudging.
pmichaud authored
76 {
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
77 # Basic tests for unpolar()
26eada7 [spec] S29-num/complex.t: fixed two tests
moritz authored
78 my $s = 2 * sqrt(2);
ad1b86b [t] Test suite refactoring.
cosimo authored
79
4bb1f86 [spec] complex.t: invalid uses of is_approx()
moritz authored
80 is_approx(4.unpolar(0), 4, "4.unpolar(0) == 4");
26eada7 [spec] S29-num/complex.t: fixed two tests
moritz authored
81 is_approx(4.unpolar($pi/4), $s + ($s)i ,"4.unpolar(pi/4) == 2+2i");
4bb1f86 [spec] complex.t: invalid uses of is_approx()
moritz authored
82 is_approx(4.unpolar($pi/2), 4i, "4.unpolar(pi/2) == 4i");
26eada7 [spec] S29-num/complex.t: fixed two tests
moritz authored
83 is_approx(4.unpolar(3*$pi/4), -$s + ($s)i,"4.unpolar(pi/4) == -2+2i");
4bb1f86 [spec] complex.t: invalid uses of is_approx()
moritz authored
84 is_approx(4.unpolar($pi), -4, "4.unpolar(pi) == -4");
626a59c [rakudo] add directives to S29-num/ and convert pod to pod6
particle authored
85 }
6512730 [t/spec] test for Complex.re and .im
moritz authored
86
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
87
88 # vim: ft=perl6
Something went wrong with that request. Please try again.