From: Francis De Brabandere <francisdb@gmail.com> VT_I8/UI8/I1/UI2/UI4/UINT cannot be produced by VBScript natively; they arrive only via COM dispatch. Extend testobj with read-only properties returning each of these VTs and exercise BSTR-vs-numeric comparison against them. The non-literal dispatch path goes through string compare against CStr(numeric), so all six cases should behave like VT_UI1/VT_CY. --- dlls/vbscript/tests/lang.vbs | 31 ++++++++++++++++++++++++++++++ dlls/vbscript/tests/run.c | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/dlls/vbscript/tests/lang.vbs b/dlls/vbscript/tests/lang.vbs index c3c79a47d06..f1cab270118 100644 --- a/dlls/vbscript/tests/lang.vbs +++ b/dlls/vbscript/tests/lang.vbs @@ -230,6 +230,37 @@ Call ok(not ("" = CCur(0)), """"" = CCur(0) should be false (no error)") Call ok(not ("10" > CByte(5)), """10"" > CByte(5) should be false (lex)") Call ok(not ("5" < CCur(10)), """5"" < CCur(10) should be false (lex)") +' VT_I8/UI8/I1/UI2/UI4/UINT can't be produced by VBScript natively; obtain +' them via a host IDispatch (testobj). Confirms BSTR vs each dispatch-only +' numeric VT goes through string compare against CStr(numeric). +Dim x_str : x_str = "5" +Call ok("5" = testobj.i8val, """5"" = testobj.i8val should be true") +Call ok(testobj.i8val = "5", "testobj.i8val = ""5"" should be true") +Call ok(x_str = testobj.i8val, "x_str = testobj.i8val (non-literal) should be true") +Call ok(not ("6" = testobj.i8val), """6"" = testobj.i8val should be false") +Call ok(not ("abc" = testobj.i8val), """abc"" = testobj.i8val should be false (no error)") +Call ok(not ("10" > testobj.i8val), """10"" > testobj.i8val should be false (lex)") + +Call ok("5" = testobj.ui8val, """5"" = testobj.ui8val should be true") +Call ok(testobj.ui8val = "5", "testobj.ui8val = ""5"" should be true") +Call ok(not ("abc" = testobj.ui8val), """abc"" = testobj.ui8val should be false (no error)") + +Call ok("5" = testobj.i1val, """5"" = testobj.i1val should be true") +Call ok(testobj.i1val = "5", "testobj.i1val = ""5"" should be true") +Call ok(not ("abc" = testobj.i1val), """abc"" = testobj.i1val should be false (no error)") + +Call ok("5" = testobj.ui2val, """5"" = testobj.ui2val should be true") +Call ok(testobj.ui2val = "5", "testobj.ui2val = ""5"" should be true") +Call ok(not ("abc" = testobj.ui2val), """abc"" = testobj.ui2val should be false (no error)") + +Call ok("5" = testobj.ui4val, """5"" = testobj.ui4val should be true") +Call ok(testobj.ui4val = "5", "testobj.ui4val = ""5"" should be true") +Call ok(not ("abc" = testobj.ui4val), """abc"" = testobj.ui4val should be false (no error)") + +Call ok("5" = testobj.uintval, """5"" = testobj.uintval should be true") +Call ok(testobj.uintval = "5", "testobj.uintval = ""5"" should be true") +Call ok(not ("abc" = testobj.uintval), """abc"" = testobj.uintval should be false (no error)") + ' --- BSTR vs numeric LITERAL: BSTR coerces to a number, parse failure raises 13. --- Dim saved_err on error resume next diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index a0fbe322ccf..ac8cf81fe55 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -152,6 +152,12 @@ DEFINE_EXPECT(OnLeaveScript); #define DISPID_TESTOBJ_PROPGET 2000 #define DISPID_TESTOBJ_PROPPUT 2001 #define DISPID_TESTOBJ_KEYWORD 2002 +#define DISPID_TESTOBJ_I8VAL 2003 +#define DISPID_TESTOBJ_UI8VAL 2004 +#define DISPID_TESTOBJ_I1VAL 2005 +#define DISPID_TESTOBJ_UI2VAL 2006 +#define DISPID_TESTOBJ_UI4VAL 2007 +#define DISPID_TESTOBJ_UINTVAL 2008 #define DISPID_COLLOBJ_RESET 3000 @@ -846,6 +852,12 @@ static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD static const dispid_t dispids[] = { { L"propget", DISPID_TESTOBJ_PROPGET, REF_EXPECT(testobj_propget_d) }, { L"propput", DISPID_TESTOBJ_PROPPUT, REF_EXPECT(testobj_propput_d) }, + { L"i8val", DISPID_TESTOBJ_I8VAL }, + { L"ui8val", DISPID_TESTOBJ_UI8VAL }, + { L"i1val", DISPID_TESTOBJ_I1VAL }, + { L"ui2val", DISPID_TESTOBJ_UI2VAL }, + { L"ui4val", DISPID_TESTOBJ_UI4VAL }, + { L"uintval", DISPID_TESTOBJ_UINTVAL }, { L"rem", DISPID_TESTOBJ_KEYWORD }, { L"true", DISPID_TESTOBJ_KEYWORD }, { L"false", DISPID_TESTOBJ_KEYWORD }, @@ -994,6 +1006,31 @@ static HRESULT WINAPI testObj_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, V_VT(pvarRes) = VT_I2; V_I2(pvarRes) = 10; return S_OK; + + case DISPID_TESTOBJ_I8VAL: + V_VT(pvarRes) = VT_I8; + V_I8(pvarRes) = 5; + return S_OK; + case DISPID_TESTOBJ_UI8VAL: + V_VT(pvarRes) = VT_UI8; + V_UI8(pvarRes) = 5; + return S_OK; + case DISPID_TESTOBJ_I1VAL: + V_VT(pvarRes) = VT_I1; + V_I1(pvarRes) = 5; + return S_OK; + case DISPID_TESTOBJ_UI2VAL: + V_VT(pvarRes) = VT_UI2; + V_UI2(pvarRes) = 5; + return S_OK; + case DISPID_TESTOBJ_UI4VAL: + V_VT(pvarRes) = VT_UI4; + V_UI4(pvarRes) = 5; + return S_OK; + case DISPID_TESTOBJ_UINTVAL: + V_VT(pvarRes) = VT_UINT; + V_UINT(pvarRes) = 5; + return S_OK; } ok(0, "unexpected call %ld\n", id); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10775