Shuai Meng : vbscript: Implemented IsNumeric.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 22 14:12:21 CDT 2014


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

Author: Shuai Meng <mengshuaicalendr at gmail.com>
Date:   Mon Jul 21 23:41:22 2014 +0800

vbscript: Implemented IsNumeric.

---

 dlls/vbscript/global.c      | 21 +++++++++++++++++++--
 dlls/vbscript/tests/api.vbs | 26 +++++++++++++++++++++++++-
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c
index 610de43..68fa388 100644
--- a/dlls/vbscript/global.c
+++ b/dlls/vbscript/global.c
@@ -91,6 +91,15 @@ static HRESULT return_bstr(VARIANT *res, BSTR str)
     return S_OK;
 }
 
+static HRESULT return_bool(VARIANT *res, BOOL val)
+{
+    if(res) {
+        V_VT(res) = VT_BOOL;
+        V_BOOL(res) = val ? VARIANT_TRUE : VARIANT_FALSE;
+    }
+    return S_OK;
+}
+
 static HRESULT return_short(VARIANT *res, short val)
 {
     if(res) {
@@ -600,8 +609,16 @@ static HRESULT Global_IsNull(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VA
 
 static HRESULT Global_IsNumeric(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    HRESULT hres;
+    double d;
+
+    TRACE("(%s)\n", debugstr_variant(arg));
+
+    assert(args_cnt == 1);
+
+    hres = to_double(arg, &d);
+
+    return return_bool(res, SUCCEEDED(hres));
 }
 
 static HRESULT Global_IsArray(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs
index 38e5e76..fbf252a 100644
--- a/dlls/vbscript/tests/api.vbs
+++ b/dlls/vbscript/tests/api.vbs
@@ -1,4 +1,3 @@
-'
 ' Copyright 2011 Jacek Caban for CodeWeavers
 '
 ' This library is free software; you can redistribute it and/or
@@ -195,6 +194,31 @@ Call ok(not isNull(4), "isNull(4) is true?")
 Call ok(not isNull("x"), "isNull(""x"") is true?")
 Call ok(isNull(Null), "isNull(Null) is not true?")
 
+Call ok(isNumeric(Empty), "isNumeric(empty) is not true?")
+Call ok(not isNumeric(Null), "isNumeric(Null) is not true?")
+Call ok(isNumeric(32767), "isNumeric(32767) is true?")
+Call ok(isNumeric(32768), "isNumeric(32768) is true?")
+Call ok(isNumeric(CSng(3242.4)), "isNumeric(CSng(3242.4)) is true?")
+Call ok(isNumeric(32768.4), "isNumeric(32768.4) is true?")
+Call ok(isNumeric(CCur(32768.4)), "isNumeric(CCur(32768.4)) is true?")
+Call ok(isNumeric("44"), "isNumeric(""44"") is true?")
+Call ok(not isNumeric("rwrf"), "isNumeric(""rwrf"") is not true?")
+Call ok(not isNumeric(Nothing), "isNumeric(Nothing) is not true?")
+Call ok(not isNumeric(New EmptyClass), "isNumeric(New EmptyClass) is not true?")
+Call ok(isNumeric(true), "isNumeric(true) is true?")
+Call ok(isNumeric(CByte(32)), "isNumeric(CByte(32)) is true?")
+Dim arr(2)
+arr(0) = 2
+arr(1) = 3
+Call ok(not isNumeric(arr), "isNumeric(arr) is not true?")
+
+Dim newObject
+Set newObject = New ValClass
+newObject.myval = 1
+Call ok(isNumeric(newObject), "isNumeric(newObject) is true?")
+newObject.myval = "test"
+Call ok(not isNumeric(newObject), "isNumeric(newObject) is not true?")
+
 Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
 
 Sub TestHex(x, ex)




More information about the wine-cvs mailing list