Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

Make 'Inf' and 'NaN' acceptable constants parameters in Rakudo #1495

Closed p6rt closed 14 years ago

p6rt commented 14 years ago

Migrated from rt.perl.org#72750 (status was 'resolved')

Searchable as RT72750$

p6rt commented 14 years ago

From @masak

\ rakudo​: sub foo(5) { say "HAI 5!" }; foo(5) \ rakudo 1d4928​: OUTPUT«HAI 5!␤» \ rakudo​: sub foo(Inf) { say "HAI INFTY!" }; foo(Inf) \ rakudo 1d4928​: OUTPUT«Malformed routine definition at line 10, near "foo(Inf) {" [...] \ rakudo​: sub foo(NaN) { say "NAN BREAD!" }; foo(NaN) \ rakudo 1d4928​: OUTPUT«Malformed routine definition at line 10, near "foo(NaN) {" [...] * masak submits rakuodbug \ I stumbled on this, which really is a TODO bug of sorts, because I wanted to see if Inf and NaN would match other types than Num. \ TimToady mentioned in the backlog that they should.

p6rt commented 14 years ago

From @bbkr

works on Kiev build tests added in t/spec/S06-multi/type-based.t

p6rt commented 14 years ago

The RT System itself - Status changed from 'new' to 'open'

p6rt commented 14 years ago

@bbkr - Status changed from 'open' to 'resolved'

p6rt commented 14 years ago

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S06-multi/type-based.t

commit 0235444cbd338b0823a093899816fb4105fedb4e Author​: bbkr \bbkr@​c213334d\-75ef\-0310\-aa23\-eaa082d1ae64 Date​: Mon Jun 28 17​:04​:34 2010 +0000

  [t/spec/S06-multi/type-based.t] tests for RT #​72750 Make Inf and NaN acceptable constants parameters in Rakudo  
  git-svn-id​: http://svn.pugscode.org/pugs@​31483 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch ```diff diff --git a/t/spec/S06-multi/type-based.t b/t/spec/S06-multi/type-based.t index 37cb2db..a218b14 100644 --- a/t/spec/S06-multi/type-based.t +++ b/t/spec/S06-multi/type-based.t @@ -7,6 +7,7 @@ plan *; #L #L +multi foo (5) { "Constant" } multi foo (Int $bar) { "Int " ~ $bar } multi foo (Str $bar) { "Str " ~ $bar } multi foo (Rat $bar) { "Rat " ~ $bar } @@ -16,9 +17,13 @@ multi foo (Sub $bar) { "Sub " ~ $bar() } multi foo (@bar) { "Positional " ~ join(', ', @bar) } multi foo (%bar) { "Associative " ~ join(', ', %bar.keys.sort) } multi foo (IO $fh) { "IO" } +multi foo (Inf) { "Inf" } +multi foo (NaN) { "NaN" } + +is foo(5), 'Constant', 'dispatched to the constant sub'; -is(foo('test'), 'Str test', 'dispatched to the Str sub'); is(foo(2), 'Int 2', 'dispatched to the Int sub'); +is(foo('test'), 'Str test', 'dispatched to the Str sub'); my $num = '4'; is(foo(1.4), 'Rat 1.4', 'dispatched to the Num sub'); @@ -34,6 +39,9 @@ is(foo(%hash), 'Associative bar, baz, foo', 'dispatched to the Associative sub') is(foo($*ERR), 'IO', 'dispatched to the IO sub'); +is foo(Inf), 'Inf', 'dispatched to the Inf sub'; +is foo(NaN), 'NaN', 'dispatched to the NaN sub'; + # You're allowed to omit the "sub" when declaring a multi sub. # L ```