Skip to content

Commit

Permalink
Don't expect .numerator to be set in DivByZero exceptions.
Browse files Browse the repository at this point in the history
BDFL's blessing: http://colabti.org/irclogger/irclogger_log/perl6-dev?date=2018-09-21#l248

We no longer carry that information. The 420 test was also wrong from the
start as it used `isa-ok` instead of just `is`.

The test in question specs a tiny portion of the behaviour of
ZDRs (Zero Denominator Rationals), and the spec does not concern itself with
any of the other behaviours. Some of those turned out to be buggy and were
fixed. Others, are still buggy and need fixing. While a certain fix is
possible while maintaing this test in passing state, that fix inflicts a
non-trivial performance penalty on many operations on *all* Rationals.

Therefore, I argue the 6.c spec is wrong to spec the behaviour of ZDRs in
such a sparse manner, without any regard to how an implementation can
meet the goals of this particular test, while maintaining bug-free behaviour
of ZDRs. Ergo, the test is wrong and shall be removed.
  • Loading branch information
zoffixznet committed Sep 23, 2018
1 parent 3a34299 commit 95c19bc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
3 changes: 0 additions & 3 deletions S03-operators/arith.t
Expand Up @@ -337,16 +337,13 @@ All uses of a zero modulus or divisor should 'die', and the
'Division by zero with infix:<div> dies and is catchable with VRef variables';

throws-like { say 0 / 0 }, X::Numeric::DivideByZero,
numerator => 0,
'Division by zero with infix:</> dies and is catchable (1)';
throws-like { say 3 / 0 }, X::Numeric::DivideByZero,
numerator => 3,
'Division by zero with infix:</> dies and is catchable (2)';
throws-like { my $x = 0; say 3.5 / $x }, X::Numeric::DivideByZero,
# numerator => 3.5, # numerator is always an Int, so we get 7
'Division by zero with infix:</> dies and is catchable with VInt/VRat variables';
throws-like { my $x = 0; say 4 / $x }, X::Numeric::DivideByZero,
numerator => 4,
'Division by zero with infix:</> dies and is catchable with VRef variables';
}

Expand Down
3 changes: 1 addition & 2 deletions S32-num/rat.t
Expand Up @@ -331,8 +331,7 @@ is 241025348275725.3352.Str, "241025348275725.3352", 'stringification of bigish
}

#RT #126391
try {say 42/(.1+.2-.3)};
isa-ok( $!.numerator, 42, "got the answer rather than 420");
try {say 42/(.1+.2-.3)}; isnt $!.numerator, 420, "no bogus errors";

# RT#126016
subtest '0.9999999999999999999999 to string conversions' => {
Expand Down

0 comments on commit 95c19bc

Please sign in to comment.