Commit bd87f97e authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

jscript: Throw range errors in Array functions.

parent 469b5972
......@@ -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))
......
......@@ -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"
}
......@@ -19,3 +19,4 @@
#include <windef.h>
#define IDS_NOT_DATE 0x138E
#define IDS_INVALID_LENGTH 0x13A5
......@@ -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();
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