Permalink
Browse files

Add Inf and NaN to Str.Numeric. Add S32-str/numeric.t to spectests.

  • Loading branch information...
pmichaud committed Jul 15, 2011
1 parent 3bf08d5 commit 8c957ea17dcedce9331f295cdc02c101be7ad69b
Showing with 6 additions and 0 deletions.
  1. +5 −0 src/core/Str.pm
  2. +1 −0 t/spectest.data
View
@@ -115,6 +115,7 @@ my class Str does Stringy {
}
method Numeric() {
+ return nqp::p6box_n(pir::set__Ns('NaN')) if self eq 'NaN';
my str $str = nqp::unbox_s(self);
my int $eos = nqp::chars($str);
my num $int;
@@ -147,6 +148,10 @@ my class Str does Stringy {
fail "missing digits after radix prefix" if nqp::islt_i($pos, 0);
$result := nqp::p6bigint(nqp::atpos($parse, 0));
}
+ elsif nqp::iseq_s(nqp::substr($str, $pos, 3), 'Inf') {
+ $result := $neg ?? -$Inf !! $Inf;
+ $pos = nqp::add_n($pos, 3);
+ }
else {
# We have some sort of number, get leading integer part
my int $p = $pos;
View
@@ -541,6 +541,7 @@ S32-str/flip.t
S32-str/lc.t # icu
S32-str/lcfirst.t # icu
S32-str/lines.t
+S32-str/numeric.t
S32-str/ords.t
# S32-str/p5chomp.t # err: Could not find sub &p5chomp
# S32-str/p5chop.t # err: Could not find sub &p5chop

0 comments on commit 8c957ea

Please sign in to comment.