Piotr Caban : jscript: Throw errors in Number functions.
Alexandre Julliard
julliard at winehq.org
Tue Jul 21 09:34:21 CDT 2009
Module: wine
Branch: master
Commit: 3afc444e7f8365fc407e28435917fe82279d1d82
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3afc444e7f8365fc407e28435917fe82279d1d82
Author: Piotr Caban <piotr.caban at gmail.com>
Date: Mon Jul 20 18:18:15 2009 +0200
jscript: Throw errors in Number functions.
---
dlls/jscript/jscript_En.rc | 2 ++
dlls/jscript/number.c | 18 ++++++------------
dlls/jscript/resource.h | 2 ++
dlls/jscript/tests/api.js | 2 ++
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc
index 40b64c9..8a0a9a9 100644
--- a/dlls/jscript/jscript_En.rc
+++ b/dlls/jscript/jscript_En.rc
@@ -22,9 +22,11 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE
{
+ IDS_INVALID_CALL_ARG "Invalid procedure call or argument"
IDS_NO_PROPERTY "Object doesn't support this property or method"
IDS_ARG_NOT_OPT "Argument not optional"
IDS_NOT_DATE "'[object]' is not a date object"
+ IDS_NOT_NUM "Number expected"
IDS_NOT_BOOL "Boolean object expected"
IDS_INVALID_LENGTH "Array length must be a finite positive integer"
}
diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c
index 5399c91..28049a9 100644
--- a/dlls/jscript/number.c
+++ b/dlls/jscript/number.c
@@ -54,10 +54,8 @@ static HRESULT Number_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA
TRACE("\n");
- if(!is_class(dispex, JSCLASS_NUMBER)) {
- FIXME("throw TypeError\n");
- return E_FAIL;
- }
+ if(!is_class(dispex, JSCLASS_NUMBER))
+ return throw_type_error(dispex->ctx, ei, IDS_NOT_NUM, NULL);
number = (NumberInstance*)dispex;
@@ -66,10 +64,8 @@ static HRESULT Number_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPA
if(FAILED(hres))
return hres;
- if(radix<2 || radix>36) {
- FIXME("throw TypeError\n");
- return E_FAIL;
- }
+ if(radix<2 || radix>36)
+ return throw_type_error(dispex->ctx, ei, IDS_INVALID_CALL_ARG, NULL);
}
if(V_VT(&number->num) == VT_I4)
@@ -208,10 +204,8 @@ static HRESULT Number_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPAR
{
TRACE("\n");
- if(!is_class(dispex, JSCLASS_NUMBER)) {
- FIXME("throw TypeError\n");
- return E_FAIL;
- }
+ if(!is_class(dispex, JSCLASS_NUMBER))
+ return throw_type_error(dispex->ctx, ei, IDS_NOT_NUM, NULL);
if(retv) {
NumberInstance *number = (NumberInstance*)dispex;
diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h
index 44c04a8..8caff6a 100644
--- a/dlls/jscript/resource.h
+++ b/dlls/jscript/resource.h
@@ -18,8 +18,10 @@
#include <windef.h>
+#define IDS_INVALID_CALL_ARG 0x0005
#define IDS_NO_PROPERTY 0x01B6
#define IDS_ARG_NOT_OPT 0x01c1
#define IDS_NOT_DATE 0x138E
+#define IDS_NOT_NUM 0x1389
#define IDS_NOT_BOOL 0x1392
#define IDS_INVALID_LENGTH 0x13A5
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index d0e5995..4cf5bb6 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1302,5 +1302,7 @@ exception_test(function() {Array(-3);}, "RangeError");
exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError");
exception_test(function() {date.setTime();}, "TypeError");
exception_test(function() {arr.test();}, "TypeError");
+exception_test(function() {arr.toString = Number.prototype.toString; arr.toString();}, "TypeError");
+exception_test(function() {(new Number(3)).toString(1);}, "TypeError");
reportSuccess();
More information about the wine-cvs
mailing list