Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix spectest errors caused by Index changes
This is actually mostly a revert of 391bdb1 , but using
new with/without functionality where appropriate
  • Loading branch information
lizmat committed Aug 8, 2015
1 parent a32c146 commit 42e19ee
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/Main.pm
Expand Up @@ -46,7 +46,7 @@ my sub MAIN_HELPER($retval = 0) {
if $passed-value ~~ /^ ( '--' | '-' | ':' ) ('/'?) (<-[0..9\.]> .*) $/ {
my ($switch, $negate, $arg) = (~$0, ?((~$1).chars), ~$2);

if $arg.index('=') {
with $arg.index('=') {
my ($name, $value) = $arg.split('=', 2);
$value = hack-val($value);
$value = $value but False if $negate;
Expand Down
12 changes: 8 additions & 4 deletions src/core/Num.pm
Expand Up @@ -27,10 +27,14 @@ my class Num does Real { # declared in BOOTSTRAP
multi method new($n) { nqp::box_n($n.Num, self) }

multi method perl(Num:D:) {
my $p = self.Str;
nqp::isnanorinf(nqp::unbox_n(self)) || $p.index('e') || $p.index('E')
?? $p
!! $p ~ 'e0';
my $res = self.Str;
if nqp::isnanorinf(nqp::unbox_n(self))
|| $res.index('e').defined
|| $res.index('E').defined {
$res;
} else {
$res ~ 'e0';
}
}

method Rat(Num:D: Real $epsilon = 1.0e-6, :$fat) {
Expand Down
5 changes: 2 additions & 3 deletions src/core/Parameter.pm
Expand Up @@ -44,7 +44,7 @@ my class Parameter { # declared in BOOTSTRAP
if $!flags +& $SIG_ELEM_IS_CAPTURE {
$sigil = '|';
} elsif $!flags +& $SIG_ELEM_IS_PARCEL {
$sigil = '\\' unless '@$%&'.index($sigil);
$sigil = '\\' without '@$%&'.index($sigil);
}
} else {
if $!flags +& $SIG_ELEM_IS_CAPTURE {
Expand Down Expand Up @@ -219,8 +219,7 @@ my class Parameter { # declared in BOOTSTRAP
if $!flags +& $SIG_ELEM_IS_CAPTURE {
$name = '|' ~ $name;
} elsif $!flags +& $SIG_ELEM_IS_PARCEL {
$name = '\\' ~ $name
unless '@$%&'.index(substr($name,0,1));
$name = '\\' ~ $name without '@$%&'.index(substr($name,0,1));
}
} else {
if $!flags +& $SIG_ELEM_IS_CAPTURE {
Expand Down
2 changes: 1 addition & 1 deletion src/core/operators.pm
Expand Up @@ -534,7 +534,7 @@ sub INDIRECT_NAME_LOOKUP($root, *@chunks) is rw {
my Str $name = @chunks.join('::');
my @parts = $name.split('::');
my $first = @parts.shift;
if @parts && '$@%&'.index(substr($first,0, 1)) {
if @parts && '$@%&'.index(substr($first,0, 1)).defined {
# move sigil from first to last chunk, because
# $Foo::Bar::baz is actually stored as Foo::Bar::$baz
my $last_idx = @parts.end;
Expand Down

0 comments on commit 42e19ee

Please sign in to comment.