Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
p6rt opened this issue Feb 13, 2010 · 5 comments
Closed

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

p6rt opened this issue Feb 13, 2010 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Feb 13, 2010

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

Searchable as RT72750$

@p6rt
Copy link
Author

p6rt commented Feb 13, 2010

From @masak

<masak> rakudo​: sub foo(5) { say "HAI 5!" }; foo(5)
<p6eval> rakudo 1d4928​: OUTPUT«HAI 5!␤»
<masak> rakudo​: sub foo(Inf) { say "HAI INFTY!" }; foo(Inf)
<p6eval> rakudo 1d4928​: OUTPUT«Malformed routine definition at line
10, near "foo(Inf) {" [...]
<masak> rakudo​: sub foo(NaN) { say "NAN BREAD!" }; foo(NaN)
<p6eval> rakudo 1d4928​: OUTPUT«Malformed routine definition at line
10, near "foo(NaN) {" [...]
* masak submits rakuodbug
<masak> 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.
<masak> TimToady mentioned in the backlog that they should.

@p6rt
Copy link
Author

p6rt commented Jun 28, 2010

From @bbkr

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

@p6rt
Copy link
Author

p6rt commented Jun 28, 2010

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

@p6rt
Copy link
Author

p6rt commented Jun 28, 2010

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

@p6rt p6rt closed this as completed Jun 28, 2010
@p6rt
Copy link
Author

p6rt commented Jun 28, 2010

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@&#8203;31483 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
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<S06/"Longname parameters">
 #L<S12/"Multisubs and Multimethods">
 
+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<S06/"Routine modifiers">
 

@p6rt p6rt added the Todo label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant