Commit 6895ad6f authored by Robert Wilhelm's avatar Robert Wilhelm Committed by Alexandre Julliard

vbscript/tests: Fix chr() tests with double-byte character sets.

There are no errors when running chr(-1) e.g. in utf-8 locale. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54003
parent ce083b37
...@@ -150,7 +150,7 @@ Call ok(Chr("120") = "x", "Chr(""120"") = " & Chr("120")) ...@@ -150,7 +150,7 @@ Call ok(Chr("120") = "x", "Chr(""120"") = " & Chr("120"))
sub testChrError sub testChrError
on error resume next on error resume next
if isEnglishLang then if MaxCharSize = 1 then
call Err.clear() call Err.clear()
call Chr(-1) call Chr(-1)
call ok(Err.number = 5, "Err.number = " & Err.number) call ok(Err.number = 5, "Err.number = " & Err.number)
...@@ -159,6 +159,13 @@ sub testChrError ...@@ -159,6 +159,13 @@ sub testChrError
call Err.clear() call Err.clear()
call Chr(256) call Chr(256)
call ok(Err.number = 5, "Err.number = " & Err.number) call ok(Err.number = 5, "Err.number = " & Err.number)
else
call Err.clear()
call Chr(-1)
call ok(Err.number = 0, "Err.number = " & Err.number)
call Err.clear()
call Chr(256)
call ok(Err.number = 0, "Err.number = " & Err.number)
end if end if
call Err.clear() call Err.clear()
......
...@@ -147,6 +147,7 @@ DEFINE_EXPECT(OnLeaveScript); ...@@ -147,6 +147,7 @@ DEFINE_EXPECT(OnLeaveScript);
#define DISPID_GLOBAL_UNKOBJ 1026 #define DISPID_GLOBAL_UNKOBJ 1026
#define DISPID_GLOBAL_THROWEXCEPTION 1027 #define DISPID_GLOBAL_THROWEXCEPTION 1027
#define DISPID_GLOBAL_ISARRAYFIXED 1028 #define DISPID_GLOBAL_ISARRAYFIXED 1028
#define DISPID_GLOBAL_MAXCHARSIZE 1029
#define DISPID_TESTOBJ_PROPGET 2000 #define DISPID_TESTOBJ_PROPGET 2000
#define DISPID_TESTOBJ_PROPPUT 2001 #define DISPID_TESTOBJ_PROPPUT 2001
...@@ -158,6 +159,7 @@ DEFINE_EXPECT(OnLeaveScript); ...@@ -158,6 +159,7 @@ DEFINE_EXPECT(OnLeaveScript);
#define MAKE_VBSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_VBS, code) #define MAKE_VBSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_VBS, code)
static BOOL strict_dispid_check, is_english, allow_ui; static BOOL strict_dispid_check, is_english, allow_ui;
static UINT MaxCharSize;
static int first_day_of_week; static int first_day_of_week;
static const char *test_name = "(null)"; static const char *test_name = "(null)";
static int test_counter; static int test_counter;
...@@ -229,6 +231,7 @@ static const char *vt2a(VARIANT *v) ...@@ -229,6 +231,7 @@ static const char *vt2a(VARIANT *v)
*/ */
static void detect_locale(void) static void detect_locale(void)
{ {
CPINFOEXA cpinfo;
HMODULE kernel32 = GetModuleHandleA("kernel32.dll"); HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
LANGID (WINAPI *pGetThreadUILanguage)(void) = (void*)GetProcAddress(kernel32, "GetThreadUILanguage"); LANGID (WINAPI *pGetThreadUILanguage)(void) = (void*)GetProcAddress(kernel32, "GetThreadUILanguage");
...@@ -236,6 +239,9 @@ static void detect_locale(void) ...@@ -236,6 +239,9 @@ static void detect_locale(void)
PRIMARYLANGID(GetUserDefaultUILanguage()) == LANG_ENGLISH && PRIMARYLANGID(GetUserDefaultUILanguage()) == LANG_ENGLISH &&
PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH); PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH);
GetCPInfoExA( CP_ACP, 0, &cpinfo );
MaxCharSize = cpinfo.MaxCharSize;
GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER, GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER,
(void*)&first_day_of_week, sizeof(first_day_of_week)); (void*)&first_day_of_week, sizeof(first_day_of_week));
first_day_of_week = 1 + (first_day_of_week + 1) % 7; first_day_of_week = 1 + (first_day_of_week + 1) % 7;
...@@ -1142,6 +1148,7 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD ...@@ -1142,6 +1148,7 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
{ L"reportSuccess", DISPID_GLOBAL_REPORTSUCCESS, REF_EXPECT(global_success_d) }, { L"reportSuccess", DISPID_GLOBAL_REPORTSUCCESS, REF_EXPECT(global_success_d) },
{ L"getVT", DISPID_GLOBAL_GETVT }, { L"getVT", DISPID_GLOBAL_GETVT },
{ L"isEnglishLang", DISPID_GLOBAL_ISENGLANG }, { L"isEnglishLang", DISPID_GLOBAL_ISENGLANG },
{ L"MaxCharSize", DISPID_GLOBAL_MAXCHARSIZE },
{ L"firstDayOfWeek", DISPID_GLOBAL_WEEKSTARTDAY }, { L"firstDayOfWeek", DISPID_GLOBAL_WEEKSTARTDAY },
{ L"globalCallback", DISPID_GLOBAL_GLOBALCALLBACK }, { L"globalCallback", DISPID_GLOBAL_GLOBALCALLBACK },
{ L"testObj", DISPID_GLOBAL_TESTOBJ }, { L"testObj", DISPID_GLOBAL_TESTOBJ },
...@@ -1264,6 +1271,11 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, ...@@ -1264,6 +1271,11 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
V_BOOL(pvarRes) = is_english ? VARIANT_TRUE : VARIANT_FALSE; V_BOOL(pvarRes) = is_english ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK; return S_OK;
case DISPID_GLOBAL_MAXCHARSIZE:
V_VT(pvarRes) = VT_I4;
V_I4(pvarRes) = MaxCharSize;
return S_OK;
case DISPID_GLOBAL_WEEKSTARTDAY: case DISPID_GLOBAL_WEEKSTARTDAY:
V_VT(pvarRes) = VT_I4; V_VT(pvarRes) = VT_I4;
V_I4(pvarRes) = first_day_of_week; V_I4(pvarRes) = first_day_of_week;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment