Skip to content

Commit 76b3925

Browse files
committed
[6.d REVIEW] Reformat for clarity
- Get rid of file-global confusingly-named var - Use clearer names for numeric constants - Use `is-deeply` to check types are right Partial orig: f884279
1 parent e3383ba commit 76b3925

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

S32-num/power.t

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use lib 't/spec/packages';
33
use Test;
44
use Test::Util;
55

6-
plan 99;
6+
plan 97;
77

88
# Real **
99
is(0 ** 0, 1, "0 ** 0 == 1");
@@ -13,19 +13,16 @@ is(4 ** 0, 1, "4 ** 0 == 1");
1313
is(4 ** 1, 4, "4 ** 1 == 4");
1414
is(4 ** 2, 16, "4 ** 2 == 16");
1515

16-
my $big-e = 4553535345364535345634543534;
17-
my $big-o = 4553535345364535345634543533;
18-
my $xno = X::Numeric::Overflow;
19-
20-
is 0 ** $big-e, 0, "0 ** $big-e == 0";
21-
is 1 ** $big-e, 1, "1 ** $big-e == 1";
22-
is 1e0 ** $big-e, 1, "1e0 ** $big-e == 1";
23-
isa-ok 1e0 ** $big-e, Num, "1e0 ** $big-e is a Num";
24-
is (-1) ** $big-e, 1, "-1 ** $big-e == 1";
25-
is (-1) ** $big-o, -1, "-1 ** $big-o == -1";
26-
throws-like { EVAL qq[ 2 ** $big-e] }, $xno, " 2 ** $big-e";
27-
throws-like { EVAL qq[(-2) ** $big-e] }, $xno, "-2 ** $big-e";
28-
throws-like { EVAL qq[(-2) ** $big-o] }, $xno, "-2 ** $big-o";
16+
my $large-even = 4553535345364535345634543534;
17+
my $large-odd = 4553535345364535345634543533;
18+
is-deeply 0 ** $large-even, 0, " 0 ** $large-even == 0";
19+
is-deeply 1 ** $large-even, 1, " 1 ** $large-even == 1";
20+
is-deeply 1e0 ** $large-even, 1e0, "1e0 ** $large-even == 1";
21+
is-deeply (-1) ** $large-even, 1, " -1 ** $large-even == 1";
22+
is-deeply (-1) ** $large-odd, -1, " -1 ** $large-odd == -1";
23+
throws-like " 2 ** $large-even", X::Numeric::Overflow, " 2 ** $large-even";
24+
throws-like "(-2) ** $large-even", X::Numeric::Overflow, "-2 ** $large-even";
25+
throws-like "(-2) ** $large-odd", X::Numeric::Overflow, "-2 ** $large-odd";
2926

3027
is(4 ** 0.5, 2, "4 ** .5 == 2");
3128
is(4 ** (1/2), 2, "4 ** (1/2) == 2 ");
@@ -126,15 +123,17 @@ is(3¹⁰, *¹⁰(3), "3¹⁰");
126123
is(3¹³, *¹³(3), "3¹³");
127124
is((-1)¹²³, *¹²³(-1), "(-1)¹²³");
128125

129-
is 0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, 0, "0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ == 0";
130-
is 1⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, 1, "1⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ == 1";
131-
is 1e0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, 1, "1e0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ == 1";
132-
isa-ok 1e0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, Num, "1e0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ is a Num";
133-
is (-1)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁵⁴, 1, "(-1)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁵⁴ == 1";
134-
is (-1)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, -1, "(-1)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ == -1";
135-
throws-like { EVAL qq[2⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵] }, $xno, "2⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ throws";
136-
throws-like { EVAL qq[(-2)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁵⁴] }, $xno, "(-2)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁵⁴ throws";
137-
throws-like { EVAL qq[(-2)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵] }, $xno, "(-2)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ throws";
126+
is-deeply 0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, 0, " 0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ == 0";
127+
is-deeply 1⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, 1, " 1⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ == 1";
128+
is-deeply 1e0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, 1e0, " 1e0⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ == 1";
129+
is-deeply (-1)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁵⁴, 1, "(-1)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁵⁴ == 1";
130+
is-deeply (-1)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵, -1, "(-1)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ == -1";
131+
throws-like '2⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵', X::Numeric::Overflow,
132+
'2⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ throws';
133+
throws-like '(-2)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁵⁴', X::Numeric::Overflow,
134+
'(-2)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁵⁴ throws';
135+
throws-like '(-2)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵', X::Numeric::Overflow,
136+
'(-2)⁴⁵⁵³⁵³⁵³⁴⁵³⁶⁴⁵³⁵³⁴⁵ throws';
138137

139138
#?rakudo.jvm 6 skip 'parsing issue on JVM: Missing required term after infix'
140139
is(4 ** ½, 2, "4 ** ½ == 2");
@@ -151,8 +150,9 @@ is-approx(27 ** -⅔, ⅑, "27 ** -⅔ == ⅑");
151150
is_run start { sleep 2; say ‘pass’; exit }; EVAL ‘say 1.0000001 ** (10 ** 8)’,
152151
{:out("pass\n"), :err(''), :0status },
153152
'raising a Rat to largish power does not throw';
154-
throws-like { EVAL qq[say 1.0000001 ** (10 ** 90000)] },
155-
$xno, "raising a Rat to a very large number throws";
153+
154+
throws-like 'say 1.0000001 ** (10 ** 90000)',
155+
X::Numeric::Overflow, "raising a Rat to a very large number throws";
156156

157157
# RT#126732
158158
#?rakudo.jvm skip 'unival NYI'

0 commit comments

Comments
 (0)