Commit 531f8336 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Added infinity and nan handling to str_to_number.

parent 4f6f8ef2
......@@ -246,26 +246,26 @@ static HRESULT str_to_number(BSTR str, VARIANT *ret)
while(isspaceW(*ptr))
ptr++;
if(*ptr == '-') {
neg = TRUE;
ptr++;
}else if(*ptr == '+') {
ptr++;
}
if(!strncmpW(ptr, infinityW, sizeof(infinityW)/sizeof(WCHAR))) {
ptr += sizeof(infinityW)/sizeof(WCHAR);
while(*ptr && isspaceW(*ptr))
ptr++;
if(*ptr) {
FIXME("NaN\n");
return E_NOTIMPL;
}
FIXME("inf\n");
return E_NOTIMPL;
if(*ptr)
num_set_nan(ret);
else
num_set_inf(ret, !neg);
return S_OK;
}
if(*ptr == '-') {
neg = TRUE;
ptr++;
}else if(*ptr == '+') {
ptr++;
}else if(*ptr == '0' && ptr[1] == 'x') {
if(*ptr == '0' && ptr[1] == 'x') {
DWORD l = 0;
ptr += 2;
......@@ -313,8 +313,8 @@ static HRESULT str_to_number(BSTR str, VARIANT *ret)
ptr++;
if(*ptr) {
FIXME("NaN\n");
return E_NOTIMPL;
num_set_nan(ret);
return S_OK;
}
if(neg)
......
......@@ -813,4 +813,11 @@ ok((Infinity < 2) === false, "(Infinity < 2) !== false");
ok((Infinity > 2) === true, "(Infinity > 2) !== true");
ok((-Infinity < 2) === true, "(-Infinity < 2) !== true");
ok(isNaN(+"test") === true, "isNaN(+'test') !== true");
ok(isNaN(+"123t") === true, "isNaN(+'123t') !== true");
ok(isNaN(+"Infinity x") === true, "isNaN(+'Infinity x') !== true");
ok(+"Infinity" === Infinity, "+'Infinity' !== Infinity");
ok(+" Infinity " === Infinity, "+' Infinity ' !== Infinity");
ok(+"-Infinity" === -Infinity, "+'-Infinity' !== -Infinity");
reportSuccess();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment