Skip to content

Commit

Permalink
Revert "Deprecate dummy arg on .Rat/.FatRat…"
Browse files Browse the repository at this point in the history
This reverts commit 4c337e8.

Conflicts:
	t/02-rakudo/v6.d-tests/01-deprecations.t
  • Loading branch information
zoffixznet committed Sep 29, 2017
1 parent a65d5f9 commit 44d5256
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 69 deletions.
14 changes: 4 additions & 10 deletions src/core/Int.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,11 @@ my class Int does Real { # declared in BOOTSTRAP
nqp::p6box_n(nqp::tonum_I(self));
}

proto method Rat(|) {*}
multi method Rat(Int:D:) { Rat.new(self, 1) }
multi method Rat(Int:D: $) {
DEPRECATED :lang-vers, '.Rat coercer without an argument', '6.d', '6.e';
self.Rat
method Rat(Int:D: $?) {
Rat.new(self, 1);
}
proto method FatRat(|) {*}
multi method FatRat(Int:D:) { FatRat.new(self, 1) }
multi method FatRat(Int:D: $) {
DEPRECATED :lang-vers, '.FatRat coercer without an argument', '6.d', '6.e';
self.FatRat
method FatRat(Int:D: $?) {
FatRat.new(self, 1);
}

method abs(Int:D:) {
Expand Down
32 changes: 4 additions & 28 deletions src/core/Rat.pm
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
# XXX: should be Rational[Int, UInt64]
my class Rat is Cool does Rational[Int, Int] {
proto method Rat(|) {*}
multi method Rat(Rat:D: ) { self }
multi method Rat(Rat:D: Real) {
DEPRECATED :lang-vers, '.Rat coercer without an argument', '6.d', '6.e';
self
}

proto method FatRat(|) {*}
multi method FatRat(Rat:D:) { FatRat.new($!numerator, $!denominator); }
multi method FatRat(Rat:D: Real) {
DEPRECATED :lang-vers, '.FatRat coercer without an argument', '6.d', '6.e';
self.FatRat
}

method Rat (Rat:D: Real $?) { self }
method FatRat(Rat:D: Real $?) { FatRat.new($!numerator, $!denominator); }
multi method perl(Rat:D:) {
if $!denominator == 1 {
$!numerator ~ '.0'
Expand All @@ -36,24 +24,12 @@ my class Rat is Cool does Rational[Int, Int] {
}

my class FatRat is Cool does Rational[Int, Int] {
proto method FatRat(|) {*}
multi method FatRat(FatRat:D:) { self }
multi method FatRat(FatRat:D: Real) {
DEPRECATED :lang-vers, '.FatRat coercer without an argument', '6.d', '6.e';
self
}

proto method Rat(|) {*}
multi method Rat(FatRat:D:) {
method FatRat(FatRat:D: Real $?) { self }
method Rat (FatRat:D: Real $?) {
$!denominator < $UINT64_UPPER
?? Rat.new($!numerator, $!denominator)
!! Failure.new("Cannot convert from FatRat to Rat because denominator is too big")
}
multi method Rat (FatRat:D: Real) {
DEPRECATED :lang-vers, '.Rat coercer without an argument', '6.d', '6.e';
self.Rat
}

multi method perl(FatRat:D:) {
"FatRat.new($!numerator, $!denominator)";
}
Expand Down
32 changes: 1 addition & 31 deletions t/02-rakudo/v6.d-tests/01-deprecations.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,5 @@ use lib <t/spec/packages/>;
use Test;
use Test::Util;

plan 4;
plan 1; ok 'dummy';

# XXX TODO: swap v6.d.PREVIEW to v6.d, once the latter is available
constant $v6d = 'v6.d.PREVIEW';

################### HELPER ROUTINES ###################################

sub test-deprecation (Str:D $lang, Str:D $code, Bool :$is-visible) {
is_run '
use \qq[$lang];
%*ENV<RAKUDO_NO_DEPRECATIONS>:delete;
\qq[$code]
', { :out(''), :err($is-visible ?? /deprecated/ !! ''), :0status },
($is-visible ?? 'shows' !! 'no ')
~ " deprecation message using $lang";
}
sub is-deprecated (|c) { test-deprecation |c, :is-visible }
sub isn't-deprecated (|c) { test-deprecation |c }
sub is-newly-deprecated (Str:D $code, Str:D $desc = "with `$code`") {
subtest $desc => {
plan 2;
test-deprecation $v6d, $code, :is-visible;
test-deprecation 'v6.c', $code;
}
}

######################################################################

is-newly-deprecated $ = 4.2.Rat: 42;
is-newly-deprecated $ = 4.2.FatRat: 42;
is-newly-deprecated $ = FatRat.new(4,2).Rat: 42;
is-newly-deprecated $ = FatRat.new(4,2).FatRat: 42;

0 comments on commit 44d5256

Please sign in to comment.