Module: wine Branch: master Commit: bd87f97e2d304420314c339cd226280bb96bd650 URL: http://source.winehq.org/git/wine.git/?a=commit;h=bd87f97e2d304420314c339cd2...
Author: Piotr Caban piotr.caban@gmail.com Date: Mon Jul 20 18:18:02 2009 +0200
jscript: Throw range errors in Array functions.
---
dlls/jscript/array.c | 12 ++++-------- dlls/jscript/jscript_En.rc | 1 + dlls/jscript/resource.h | 1 + dlls/jscript/tests/api.js | 1 + 4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 9b43142..0af6df1 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -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)) diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc index cee2718..161b761 100644 --- a/dlls/jscript/jscript_En.rc +++ b/dlls/jscript/jscript_En.rc @@ -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" } diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h index e0f6661..5041e27 100644 --- a/dlls/jscript/resource.h +++ b/dlls/jscript/resource.h @@ -19,3 +19,4 @@ #include <windef.h>
#define IDS_NOT_DATE 0x138E +#define IDS_INVALID_LENGTH 0x13A5 diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 36fb191..f36ec80 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -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();