b=625503; convert NaN correctly with typed array array conversion; r=waldo, a=dvander

This commit is contained in:
Vladimir Vukicevic 2011-01-14 10:46:22 -08:00
parent 6afc30e375
commit b4fe058f4f
2 changed files with 10 additions and 2 deletions

View File

@ -1116,8 +1116,12 @@ class TypedArrayTemplate
if (v.isInt32())
return NativeType(v.toInt32());
if (v.isDouble())
return NativeType(v.toDouble());
if (v.isDouble()) {
double d = v.toDouble();
if (!ArrayTypeIsFloatingPoint() && JS_UNLIKELY(JSDOUBLE_IS_NaN(d)))
return NativeType(int32(0));
return NativeType(d);
}
if (v.isPrimitive() && !v.isMagic()) {
jsdouble dval;

View File

@ -333,6 +333,10 @@ function test()
checkThrows(function() new Float32Array(null));
checkThrows(function() new Float32Array(undefined));
// check that NaN conversions happen correctly with array conversions
check(function() (new Int32Array([NaN])[0]) == 0);
check(function() { var q = new Float32Array([NaN])[0]; return q != q; });
print ("done");
reportCompare(0, TestFailCount, "typed array tests");