Commit 4438b270 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

vbscript/tests: Fix test for WeekDayName(foo, bar, 0).

parent 1354c0f3
......@@ -594,7 +594,6 @@ if isEnglishLang then
Call ok(WeekDayName(1, false) = "Sunday", "WeekDayName(1, false) = " & WeekDayName(1, false))
Call ok(WeekDayName(1, true) = "Sun", "WeekDayName(1, true) = " & WeekDayName(1, true))
Call ok(WeekDayName(1, 10) = "Sun", "WeekDayName(1, 10) = " & WeekDayName(1, 10))
Call ok(WeekDayName(1, true, 0) = "Sun", "WeekDayName(1, true, 0) = " & WeekDayName(1, true, 0))
Call ok(WeekDayName(1, true, 2) = "Mon", "WeekDayName(1, true, 2) = " & WeekDayName(1, true, 2))
Call ok(WeekDayName(1, true, 2.5) = "Mon", "WeekDayName(1, true, 2.5) = " & WeekDayName(1, true, 2.5))
Call ok(WeekDayName(1, true, 1.5) = "Mon", "WeekDayName(1, true, 1.5) = " & WeekDayName(1, true, 1.5))
......@@ -609,6 +608,9 @@ if isEnglishLang then
Call ok(MonthName(12, true) = "Dec", "MonthName(12, true) = " & MonthName(12, true))
end if
Call ok(WeekDayName(1, true, 0) = WeekDayName(1, true, firstDayOfWeek), _
"WeekDayName(1, true, 0) = " & WeekDayName(1, true, 0))
Call ok(getVT(Now()) = "VT_DATE", "getVT(Now()) = " & getVT(Now()))
Call ok(vbOKOnly = 0, "vbOKOnly = " & vbOKOnly)
......
......@@ -123,6 +123,7 @@ DEFINE_EXPECT(OnScriptError);
#define DISPID_GLOBAL_LETOBJ 1018
#define DISPID_GLOBAL_SETOBJ 1019
#define DISPID_GLOBAL_TODO_WINE_OK 1020
#define DISPID_GLOBAL_WEEKSTARTDAY 1021
#define DISPID_TESTOBJ_PROPGET 2000
#define DISPID_TESTOBJ_PROPPUT 2001
......@@ -136,6 +137,7 @@ static const WCHAR testW[] = {'t','e','s','t',0};
static const WCHAR emptyW[] = {0};
static BOOL strict_dispid_check, is_english, allow_ui;
static int first_day_of_week;
static const char *test_name = "(null)";
static int test_counter;
static SCRIPTUICHANDLING uic_handling = SCRIPTUICHANDLING_NOUIERROR;
......@@ -204,27 +206,23 @@ static const char *vt2a(VARIANT *v)
}
}
/* Returns true if the user interface is in English. Note that this does not
* presume of the formatting of dates, numbers, etc.
/* Sets is_english to true if the user interface is in English. Note that this
* does not presume the formatting of dates, numbers, etc.
* Sets first_day_of_week to 1 if Sunday, 2 if Monday, and so on.
*/
static BOOL is_lang_english(void)
static void detect_locale(void)
{
static HMODULE hkernel32 = NULL;
static LANGID (WINAPI *pGetThreadUILanguage)(void) = NULL;
static LANGID (WINAPI *pGetUserDefaultUILanguage)(void) = NULL;
HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
LANGID (WINAPI *pGetThreadUILanguage)(void) = (void*)GetProcAddress(kernel32, "GetThreadUILanguage");
if (!hkernel32)
{
hkernel32 = GetModuleHandleA("kernel32.dll");
pGetThreadUILanguage = (void*)GetProcAddress(hkernel32, "GetThreadUILanguage");
pGetUserDefaultUILanguage = (void*)GetProcAddress(hkernel32, "GetUserDefaultUILanguage");
}
if (pGetThreadUILanguage && PRIMARYLANGID(pGetThreadUILanguage()) != LANG_ENGLISH)
return FALSE;
if (pGetUserDefaultUILanguage && PRIMARYLANGID(pGetUserDefaultUILanguage()) != LANG_ENGLISH)
return FALSE;
is_english = ((!pGetThreadUILanguage || PRIMARYLANGID(pGetThreadUILanguage()) == LANG_ENGLISH) &&
PRIMARYLANGID(GetUserDefaultUILanguage()) == LANG_ENGLISH &&
PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH);
return PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH;
GetLocaleInfoA(pGetThreadUILanguage ? pGetThreadUILanguage() : GetUserDefaultUILanguage(),
LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER,
(void*)&first_day_of_week, sizeof(first_day_of_week));
first_day_of_week = 1 + (first_day_of_week + 1) % 7;
}
static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
......@@ -1010,6 +1008,11 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD
*pid = DISPID_GLOBAL_ISENGLANG;
return S_OK;
}
if(!strcmp_wa(bstrName, "firstDayOfWeek")) {
test_grfdex(grfdex, fdexNameCaseInsensitive);
*pid = DISPID_GLOBAL_WEEKSTARTDAY;
return S_OK;
}
if(!strcmp_wa(bstrName, "testObj")) {
test_grfdex(grfdex, fdexNameCaseInsensitive);
*pid = DISPID_GLOBAL_TESTOBJ;
......@@ -1183,6 +1186,11 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid,
V_BOOL(pvarRes) = is_english ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
case DISPID_GLOBAL_WEEKSTARTDAY:
V_VT(pvarRes) = VT_I4;
V_I4(pvarRes) = first_day_of_week;
return S_OK;
case DISPID_GLOBAL_VBVAR:
CHECK_EXPECT(global_vbvar_i);
......@@ -2355,7 +2363,7 @@ START_TEST(run)
int argc;
char **argv;
is_english = is_lang_english();
detect_locale();
if(!is_english)
skip("Skipping some tests in non-English locale\n");
......
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