On 04/23/14 02:20, Shuai Meng wrote:
--- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -557,8 +557,41 @@ 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;
- TRACE("(%s)\n", debugstr_variant(arg));
- assert(args_cnt == 1);
- if(res) {
V_VT(res) = VT_BOOL;
You can't assume that res is non-NULL.
switch(V_VT(arg)) {
case VT_UI1:
case VT_I2:
case VT_I4:
case VT_I8:
case VT_R4:
case VT_R8:
case VT_BOOL:
case VT_EMPTY:
case VT_CY:
V_BOOL(res) = VARIANT_TRUE;
break;
case VT_BSTR: {
HRESULT hRet;
double d;
hRet = VarR8FromStr(V_BSTR(arg), LOCALE_USER_DEFAULT, 0, &d);
if(SUCCEEDED(hRet))
V_BOOL(res) = VARIANT_TRUE;
else
V_BOOL(res) = VARIANT_FALSE;
break;
}
default:
V_BOOL(res) = VARIANT_FALSE;
break;
That's a risky assumption. There are tons of other VT_* types possible and at least VT_UI2, VT_UI4 and alike should most likely return true. It's much safer to add explicit list of *tested* cases to return false and FIXME(); return E_NOTIMPL for other cases.
}
- }
- return S_OK;
}
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 beee4d4..cf63fb9 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -170,6 +170,25 @@ 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(not isNumeric(CDate(32)), "isNumeric(CDate(32)) 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?")
Call ok(getVT(err) = "VT_DISPATCH", "getVT(err) = " & getVT(err))
Your tests depend on your previous patches that were not committed and I already commented them. Please concentrate on getting them committed first.
Jacek