Piotr Caban : jscript: Throw type errors in Boolean functions.

Alexandre Julliard julliard at winehq.org
Tue Jul 21 09:34:13 CDT 2009


Module: wine
Branch: master
Commit: 77e93ad8c7dca4e68b2f6b6cc9c6b9325f83de8e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=77e93ad8c7dca4e68b2f6b6cc9c6b9325f83de8e

Author: Piotr Caban <piotr.caban at gmail.com>
Date:   Mon Jul 20 18:18:05 2009 +0200

jscript: Throw type errors in Boolean functions.

---

 dlls/jscript/bool.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/bool.c b/dlls/jscript/bool.c
index ab9ef43..2b5152a 100644
--- a/dlls/jscript/bool.c
+++ b/dlls/jscript/bool.c
@@ -46,10 +46,8 @@ static HRESULT Bool_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARA
 
     TRACE("\n");
 
-    if(!is_class(dispex, JSCLASS_BOOLEAN)) {
-        FIXME("throw TypeError\n");
-        return E_FAIL;
-    }
+    if(!is_class(dispex, JSCLASS_BOOLEAN))
+        return throw_type_error(dispex->ctx, ei, IDS_NOT_BOOL, NULL);
 
     if(retv) {
         BoolInstance *bool = (BoolInstance*)dispex;
@@ -81,10 +79,8 @@ static HRESULT Bool_valueOf(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM
 {
     TRACE("\n");
 
-    if(!is_class(dispex, JSCLASS_BOOLEAN)) {
-        FIXME("throw TypeError\n");
-        return E_FAIL;
-    }
+    if(!is_class(dispex, JSCLASS_BOOLEAN))
+        return throw_type_error(dispex->ctx, ei, IDS_NOT_BOOL, NULL);
 
     if(retv) {
         BoolInstance *bool = (BoolInstance*)dispex;
diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc
index 161b761..3a5f9d2 100644
--- a/dlls/jscript/jscript_En.rc
+++ b/dlls/jscript/jscript_En.rc
@@ -23,5 +23,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
 STRINGTABLE DISCARDABLE
 {
     IDS_NOT_DATE            "'[object]' is not a date object"
+    IDS_NOT_BOOL            "Boolean object expected"
     IDS_INVALID_LENGTH      "Array length must be a finite positive integer"
 }
diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h
index 5041e27..6c5f8b0 100644
--- a/dlls/jscript/resource.h
+++ b/dlls/jscript/resource.h
@@ -19,4 +19,5 @@
 #include <windef.h>
 
 #define IDS_NOT_DATE                        0x138E
+#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 f36ec80..cae853b 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -1299,5 +1299,6 @@ function exception_test(func, type) {
 }
 exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError");
 exception_test(function() {Array(-3);}, "RangeError");
+exception_test(function() {arr.toString = Boolean.prototype.toString; arr.toString();}, "TypeError");
 
 reportSuccess();




More information about the wine-cvs mailing list