Skip to content

Commit

Permalink
Fix the default sort compare function for %TypedArray%s (#445)
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
  • Loading branch information
Robert Fancsik authored and bbrto21 committed Oct 2, 2019
1 parent 67e18df commit 89bb5e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/runtime/GlobalObjectBuiltinTypedArray.cpp
Expand Up @@ -850,7 +850,23 @@ static Value builtinTypedArraySort(ExecutionState& state, Value thisValue, size_
}
return (v.toNumber(state) < 0);
} else {
return (x.toNumber(state) < y.toNumber(state));
double xNum = x.asNumber();
double yNum = y.asNumber();

// 22.2.3.25.3-10
if (std::isnan(xNum)) {
return false;
}

if (std::isnan(yNum)) {
return true;
}

if (xNum == 0.0 && xNum == yNum) {
return std::signbit(xNum);
}

return xNum <= yNum;
} });
return O;
}
Expand Down
1 change: 0 additions & 1 deletion tools/test/v8/v8.mjsunit.status
Expand Up @@ -696,7 +696,6 @@
'es6/typedarray-neutered' : [SKIP],
'es6/typedarray-reduce' : [SKIP],
'es6/typedarray-set-length' : [SKIP],
'es6/typedarray-sort' : [SKIP],
'es6/typedarray-species' : [SKIP],
'es6/typedarray-tostring' : [SKIP],
'es6/unicode-character-ranges' : [SKIP],
Expand Down

0 comments on commit 89bb5e4

Please sign in to comment.