jscript: Throw range errors in Array functions.

This commit is contained in:
Piotr Caban 2009-07-20 18:18:02 +02:00 committed by Alexandre Julliard
parent 469b597212
commit bd87f97e2d
4 changed files with 7 additions and 8 deletions

View File

@ -74,10 +74,8 @@ static HRESULT Array_length(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
else
len = floor(V_R8(&num));
if(len!=(DWORD)len) {
FIXME("Throw RangeError\n");
return E_FAIL;
}
if(len!=(DWORD)len)
return throw_range_error(dispex->ctx, ei, IDS_INVALID_LENGTH, NULL);
for(i=len; i<This->length; i++) {
hres = jsdisp_delete_idx(dispex, i);
@ -850,10 +848,8 @@ static HRESULT ArrayConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISP
case DISPATCH_METHOD:
case DISPATCH_CONSTRUCT: {
if(arg_cnt(dp) == 1 && V_VT((arg_var = get_arg(dp, 0))) == VT_I4) {
if(V_I4(arg_var) < 0) {
FIXME("throw RangeError\n");
return E_FAIL;
}
if(V_I4(arg_var) < 0)
return throw_range_error(dispex->ctx, ei, IDS_INVALID_LENGTH, NULL);
hres = create_array(dispex->ctx, V_I4(arg_var), &obj);
if(FAILED(hres))

View File

@ -23,4 +23,5 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE
{
IDS_NOT_DATE "'[object]' is not a date object"
IDS_INVALID_LENGTH "Array length must be a finite positive integer"
}

View File

@ -19,3 +19,4 @@
#include <windef.h>
#define IDS_NOT_DATE 0x138E
#define IDS_INVALID_LENGTH 0x13A5

View File

@ -1298,5 +1298,6 @@ function exception_test(func, type) {
ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString());
}
exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError");
exception_test(function() {Array(-3);}, "RangeError");
reportSuccess();