From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/vbscript/global.c | 32 +++++++++++++++++++++++++++++--- dlls/vbscript/tests/api.vbs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 424fbadda6c..471523c0c8f 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -2951,10 +2951,36 @@ static HRESULT Global_FormatNumber(BuiltinDisp *This, VARIANT *arg, unsigned arg return E_NOTIMPL; }
-static HRESULT Global_FormatCurrency(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) +static HRESULT Global_FormatCurrency(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res) { - FIXME("\n"); - return E_NOTIMPL; + union + { + struct + { + int num_dig, inc_lead, use_parens, group; + } s; + int val[4]; + } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 }; + HRESULT hres; + BSTR str; + int i; + + TRACE("\n"); + + assert(1 <= args_cnt && args_cnt <= 5); + + for (i = 1; i < args_cnt; ++i) + { + if (V_VT(args+i) == VT_ERROR) continue; + if (V_VT(args+i) == VT_NULL) return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE); + if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres; + } + + hres = VarFormatCurrency(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens, + int_args.s.group, 0, &str); + if (FAILED(hres)) return hres; + + return return_bstr(res, str); }
static HRESULT Global_FormatPercent(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index 0e47f428d09..391aa0b63fb 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -2339,4 +2339,40 @@ end sub call testRandomize() call testRandomizeError()
+sub testFormatCurrencyError() + on error resume next + dim x + call Err.clear() + x = FormatCurrency(null) + call ok(Err.number = 13, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatCurrency(1000,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatCurrency(1000,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatCurrency(1000,0,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatCurrency(1000,0,0,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) +end sub + +sub testFormatCurrency() + dim x + + x = FormatCurrency(0) + x = FormatCurrency(-1000,,,-1) + call ok(getVT(x) = "VT_BSTR*", "getVT = " & getVT(x)) +end sub + +call testFormatCurrency() +call testFormatCurrencyError() + Call reportSuccess()
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/vbscript/global.c | 32 +++++++++++++++++++++++++++++--- dlls/vbscript/tests/api.vbs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 471523c0c8f..73049a5e77f 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -2983,10 +2983,36 @@ static HRESULT Global_FormatCurrency(BuiltinDisp *This, VARIANT *args, unsigned return return_bstr(res, str); }
-static HRESULT Global_FormatPercent(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) +static HRESULT Global_FormatPercent(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res) { - FIXME("\n"); - return E_NOTIMPL; + union + { + struct + { + int num_dig, inc_lead, use_parens, group; + } s; + int val[4]; + } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 }; + HRESULT hres; + BSTR str; + int i; + + TRACE("\n"); + + assert(1 <= args_cnt && args_cnt <= 5); + + for (i = 1; i < args_cnt; ++i) + { + if (V_VT(args+i) == VT_ERROR) continue; + if (V_VT(args+i) == VT_NULL) return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE); + if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres; + } + + hres = VarFormatPercent(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens, + int_args.s.group, 0, &str); + if (FAILED(hres)) return hres; + + return return_bstr(res, str); }
static HRESULT Global_FormatDateTime(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index 391aa0b63fb..ecae726d229 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -2375,4 +2375,40 @@ end sub call testFormatCurrency() call testFormatCurrencyError()
+sub testFormatPercentError() + on error resume next + dim x + call Err.clear() + x = FormatPercent(null) + call ok(Err.number = 13, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatPercent(.10,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatPercent(.10,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatPercent(.10,0,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatPercent(.10,0,0,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) +end sub + +sub testFormatPercent() + dim x + + x = FormatPercent(0) + x = FormatPercent(.12,,,-1) + call ok(getVT(x) = "VT_BSTR*", "getVT = " & getVT(x)) +end sub + +call testFormatPercent() +call testFormatPercentError() + Call reportSuccess()
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/vbscript/global.c | 28 +++++++++++++++++++++++++--- dlls/vbscript/tests/api.vbs | 25 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index 73049a5e77f..f6995cb55d7 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -3015,10 +3015,32 @@ static HRESULT Global_FormatPercent(BuiltinDisp *This, VARIANT *args, unsigned a return return_bstr(res, str); }
-static HRESULT Global_FormatDateTime(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) +static HRESULT Global_FormatDateTime(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res) { - FIXME("\n"); - return E_NOTIMPL; + int format = 0; + HRESULT hres; + BSTR str; + + TRACE("\n"); + + assert(1 <= args_cnt && args_cnt <= 2); + + if (V_VT(args) == VT_NULL) + return MAKE_VBSERROR(VBSE_TYPE_MISMATCH); + + if (args_cnt == 2) + { + if (V_VT(args+1) == VT_NULL) return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE); + if (V_VT(args+1) != VT_ERROR) + { + if (FAILED(hres = to_int(args+1, &format))) return hres; + } + } + + hres = VarFormatDateTime(args, format, 0, &str); + if (FAILED(hres)) return hres; + + return return_bstr(res, str); }
static HRESULT Global_WeekdayName(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res) diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index ecae726d229..01e034bd73e 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -2411,4 +2411,29 @@ end sub call testFormatPercent() call testFormatPercentError()
+sub testFormatDateTimeError() + on error resume next + dim x + call Err.clear() + x = FormatDateTime(null) + call ok(Err.number = 13, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatDateTime(.10,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) +end sub + +sub testFormatDateTime() + dim x + + x = FormatDateTime(0) + call ok(getVT(x) = "VT_BSTR*", "getVT = " & getVT(x)) + x = FormatDateTime(0.1,1) + call ok(getVT(x) = "VT_BSTR*", "getVT = " & getVT(x)) +end sub + +call testFormatDateTime() +call testFormatDateTimeError() + Call reportSuccess()
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/vbscript/global.c | 32 +++++++++++++++++++++++++++++--- dlls/vbscript/tests/api.vbs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index f6995cb55d7..d60374f9e87 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -2945,10 +2945,36 @@ static HRESULT Global_ScriptEngineBuildVersion(BuiltinDisp *This, VARIANT *arg, return return_int(res, VBSCRIPT_BUILD_VERSION); }
-static HRESULT Global_FormatNumber(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) +static HRESULT Global_FormatNumber(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res) { - FIXME("\n"); - return E_NOTIMPL; + union + { + struct + { + int num_dig, inc_lead, use_parens, group; + } s; + int val[4]; + } int_args = { .s.num_dig = -1, .s.inc_lead = -2, .s.use_parens = -2, .s.group = -2 }; + HRESULT hres; + BSTR str; + int i; + + TRACE("\n"); + + assert(1 <= args_cnt && args_cnt <= 5); + + for (i = 1; i < args_cnt; ++i) + { + if (V_VT(args+i) == VT_ERROR) continue; + if (V_VT(args+i) == VT_NULL) return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE); + if (FAILED(hres = to_int(args+i, &int_args.val[i-1]))) return hres; + } + + hres = VarFormatNumber(args, int_args.s.num_dig, int_args.s.inc_lead, int_args.s.use_parens, + int_args.s.group, 0, &str); + if (FAILED(hres)) return hres; + + return return_bstr(res, str); }
static HRESULT Global_FormatCurrency(BuiltinDisp *This, VARIANT *args, unsigned args_cnt, VARIANT *res) diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index 01e034bd73e..459d3ace33e 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -2436,4 +2436,40 @@ end sub call testFormatDateTime() call testFormatDateTimeError()
+sub testFormatNumberError() + on error resume next + dim x + call Err.clear() + x = FormatNumber(null) + call ok(Err.number = 13, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatNumber(.10,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatNumber(.10,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatNumber(.10,0,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) + call Err.clear() + x = FormatNumber(.10,0,0,0,null) + call ok(Err.number = 94, "Err.number = " & Err.number) + call ok(getVT(x) = "VT_EMPTY*", "getVT = " & getVT(x)) +end sub + +sub testFormatNumber() + dim x + + x = FormatNumber(0) + x = FormatNumber(.12,,,-1) + call ok(getVT(x) = "VT_BSTR*", "getVT = " & getVT(x)) +end sub + +call testFormatNumber() +call testFormatNumberError() + Call reportSuccess()
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126235
Your paranoid android.
=== debian11 (32 bit report) ===
d3d8: device.c:3365: Test failed: Expected message 0x1c for window 0x1, but didn't receive it
ddraw: ddraw4.c:17853: Test failed: Got unexpected caps 0x421350.
This merge request was approved by Jacek Caban.