vbscript: Implemented CCur.

This commit is contained in:
Shuai Meng 2014-05-20 09:05:07 +08:00 committed by Alexandre Julliard
parent f82cb70033
commit 14f68a988b
3 changed files with 68 additions and 2 deletions

View file

@ -375,8 +375,25 @@ static HRESULT show_msgbox(script_ctx_t *ctx, BSTR prompt, VARIANT *res)
static HRESULT Global_CCur(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)
{
FIXME("\n");
return E_NOTIMPL;
VARIANT v;
HRESULT hres;
TRACE("%s\n", debugstr_variant(arg));
assert(args_cnt == 1);
V_VT(&v) = VT_EMPTY;
hres = VariantChangeType(&v, arg, 0, VT_CY);
if(FAILED(hres))
return hres;
if(!res) {
VariantClear(&v);
return DISP_E_BADVARTYPE;
}
*res = v;
return S_OK;
}
static HRESULT Global_CInt(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIANT *res)

View file

@ -587,4 +587,51 @@ MyObject.myval = 0
Call ok(CByte(MyObject) = 0, "CByte(MyObject) = " & CByte(MyObject))
Call ok(getVT(CByte(MyObject)) = "VT_UI1", "getVT(CByte(MyObject)) = " & getVT(CByte(MyObject)))
Sub testCCurError(strings, error_num1, error_num2)
on error resume next
Dim x
Call Err.clear()
x = CCur(strings)
Call ok(Err.number = error_num1, "Err.number = " & Err.number)
Call Err.clear()
Call CCur(strings)
Call ok(Err.number = error_num2, "Err.number = " & Err.number)
End Sub
Call ok(CCur(Empty) = 0, "CCur(Empty) = " & CCur(Empty))
Call ok(getVT(CCur(Empty)) = "VT_CY", "getVT(CCur(Empty)) = " & getVT(CCur(Empty)))
Call ok(CCur(-32768) = -32768, "CCur(-32768) = " & CCur(-32768))
Call ok(getVT(CCur(-32768)) = "VT_CY", "getVT(CCur(-32768)) = " & getVT(CCur(-32768)))
Call ok(CCur(32768) = 32768, "CCur(32768) = " & CCur(32768))
Call ok(getVT(CCur(32768)) = "VT_CY", "getVT(CCur(32768)) = " & getVT(CCur(32768)))
Call ok(CCur(0.000149) = 0.0001, "CCur(0.000149) = " & CCur(0.000149))
Call ok(getVT(CCur(0.000149)) = "VT_CY", "getVT(CCur(0.000149)) = " & getVT(CCur(0.000149)))
Call ok(CCur(2147483647.99) = 2147483647.99, "CCur(2147483647.99) = " & CCur(2147483647.99))
Call ok(getVT(CCur(2147483647.99)) = "VT_CY", "getVT(CCur(2147483647.99)) = " & getVT(CCur(2147483647.99)))
Call ok(CCur("-1") = -1, "CCur(""-1"") = " & CCur("-1"))
Call ok(getVT(CCur("-1")) = "VT_CY", "getVT(CCur(""-1"")) = " & getVT(CCur("-1")))
If isEnglishLang Then
Call ok(CCur("-0.5") = -0.5, "CCur(""-0.5"") = " & CCur("-0.5"))
Call ok(getVT(CCur("-0.5")) = "VT_CY", "getVT(CCur(""-0.5"")) = " & getVT(CCur("-0.5")))
End If
Call testCCurError("", 13, 13)
Call testCCurError("-1", 0, 458)
Call testCCurError("TRUE", 13, 13)
Call testCCurError("FALSE", 13, 13)
Call testCCurError("#TRue#", 13, 13)
Call testCCurError("#fAlSE#", 13, 13)
Call testCCurError(1, 0, 458)
Call ok(CCur(True) = -1, "CCur(True) = " & CCur(True))
Call ok(getVT(CCur(True)) = "VT_CY", "getVT(CCur(True)) = " & getVT(CCur(True)))
Call ok(CCur(False) = 0, "CCur(False) = " & CCur(False))
Call ok(getVT(CCur(False)) = "VT_CY", "getVT(CCur(False)) = " & getVT(CCur(False)))
MyObject.myval = 0.1
Call ok(CCur(MyObject) = 0.1, "CCur(MyObject) = " & CCur(MyObject))
Call ok(getVT(CCur(MyObject)) = "VT_CY", "getVT(CCur(MyObject)) = " & getVT(CCur(MyObject)))
MyObject.myval = 0
Call ok(CCur(MyObject) = 0, "CCur(MyObject) = " & CCur(MyObject))
Call ok(getVT(CCur(MyObject)) = "VT_CY", "getVT(CCur(MyObject)) = " & getVT(CCur(MyObject)))
Call reportSuccess()

View file

@ -169,6 +169,8 @@ static const char *vt2a(VARIANT *v)
return "VT_I4";
case VT_R8:
return "VT_R8";
case VT_CY:
return "VT_CY";
case VT_DATE:
return "VT_DATE";
case VT_BSTR: