From: Shuai Meng Subject: [PATCH 1/2] vbscript: Implemented Fix Message-Id: <53E091EF.7040208@gmail.com> Date: Tue, 05 Aug 2014 16:12:31 +0800 testbot: https://testbot.winehq.org/JobDetails.pl?Key=8290 --- dlls/vbscript/global.c | 19 +++++++++++++++++-- dlls/vbscript/tests/api.vbs | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index dc41db5..d40ed9e 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -1277,8 +1277,23 @@ static HRESULT Global_Abs(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIA static HRESULT Global_Fix(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) { - FIXME("\n"); - return E_NOTIMPL; + HRESULT hres; + VARIANT dst; + + TRACE("(%s)\n", debugstr_variant(arg)); + + assert(args_cnt == 1); + + hres = VarFix(arg, &dst); + if(FAILED(hres)) + return hres; + + if (res) + *res = dst; + else + VariantClear(&dst); + + return S_OK; } static HRESULT Global_Int(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 fbf252a..481b0cb 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -984,4 +984,29 @@ End Sub Call testAbsError("strings", 13, 13) Call testAbsError(-4, 0, 0) +Call ok(Fix(Empty) = 0, "Fix(Empty) = " & Fix(Empty)) +Call ok(getVT(Fix(Empty)) = "VT_I2", "getVT(Fix(Empty)) = " & getVT(Fix(Empty))) +Call ok(Fix(CCur(-0.99)) = 0, "Fix(CCur(-0.99)) = " & Fix(CCur(-0.99))) +Call ok(getVT(Fix(CCur(-0.99))) = "VT_CY", "getVT(Fix(CCur(-0.99))) = " & getVT(Fix(CCur(-0.99)))) +Call ok(Fix(1.99) = 1, "Fix(1.99) = " & Fix(1.99)) +Call ok(getVT(Fix(1.99)) = "VT_R8", "getVT(Fix(1.99)) = " & getVT(Fix(1.99))) +Call ok(Fix(-1.99) = -1, "Fix(-1.99) = " & Fix(-1.99)) +Call ok(getVT(Fix(-1.99)) = "VT_R8", "getVT(Fix(-1.99)) = " & getVT(Fix(-1.99))) +If isEnglishLang Then + Call ok(Fix("1.99") = 1, "Fix(""1.99"") = " & Fix("1.99")) + Call ok(getVT(Fix("1.99")) = "VT_R8", "getVT(Fix(""1.99"")) = " & getVT(Fix("1.99"))) + Call ok(Fix("-1.99") = -1, "Fix(""-1.99"") = " & Fix("-1.99")) + Call ok(getVT(Fix("-1.99")) = "VT_R8", "getVT(Fix(""-1.99"")) = " & getVT(Fix("-1.99"))) +End If +Call ok(Fix(True) = -1, "Fix(True) = " & Fix(True)) +Call ok(getVT(Fix(True)) = "VT_I2", "getVT(Fix(True)) = " & getVT(Fix(True))) +Call ok(Fix(False) = 0, "Fix(False) = " & Fix(False)) +Call ok(getVT(Fix(False)) = "VT_I2", "getVT(Fix(False)) = " & getVT(Fix(False))) +MyObject.myval = 2.5 +Call ok(Fix(MyObject) = 2, "Fix(MyObject) = " & Fix(MyObject)) +Call ok(getVT(Fix(MyObject)) = "VT_R8", "getVT(Fix(MyObject)) = " & getVT(Fix(MyObject))) +MyObject.myval = -2.5 +Call ok(Fix(MyObject) = -2, "Fix(MyObject) = " & Fix(MyObject)) +Call ok(getVT(Fix(MyObject)) = "VT_R8", "getVT(Fix(MyObject)) = " & getVT(Fix(MyObject))) + Call reportSuccess()