/
advent2009-day14.t
46 lines (34 loc) 路 1014 Bytes
/
advent2009-day14.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# http://perl6advent.wordpress.com/2009/12/14/day-14-going-to-the-rats/
use v6;
use Test;
plan 21;
is (3/7).WHAT.gist, "Rat()";
is_approx (3/7), 0.4285714;
is_approx (3/7).Num + (2/7).Num + (2/7).Num - 1, -1.1102230e-16;
is 3/7 + 2/7 + 2/7 - 1, 0;
#?rakudo todo "New Rat.perl"
is (3/7).perl, "<3/7>";
is (3/7).numerator, 3;
is (3/7).denominator, 7;
is (3/7).nude.join('|'), "3|7";
my $a = 1/60000 + 1/60000;
is $a.WHAT.gist, "Rat()";
is_approx $a, 3.3333333e-05;
#?rakudo todo "New Rat.perl"
is $a.perl, "<1/30000>";
$a = 1/60000 + 1/60001;
ok $a ~~ Rat || $a ~~ Num, "1/60000 + 1/60001 must be a Rat or a Num";
is_approx $a, 3.333305e-05;
$a = cos(1/60000);
ok $a ~~Num, 'cos() returned a Num';
is_approx $a, 0.99999999;
#?rakudo 2 todo "New Rat.perl"
is 3.14.Rat.perl, "<157/50>";
is pi.Rat.perl, "<355/113>";
#?rakudo todo 'nom regression'
is pi.Rat(1e-10).perl, "<312689/99532>";
is 1.75.WHAT.gist, "Rat()";
#?rakudo 2 todo "New Rat.perl"
is 1.75.perl, "<7/4>";
is 1.752.perl, "<219/125>";
done;