vbscript: Fixed Hex.
This commit is contained in:
parent
7f977e5d2f
commit
287d419e5e
|
@ -544,6 +544,8 @@ static HRESULT Global_Hex(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIA
|
|||
{
|
||||
WCHAR buf[17], *ptr;
|
||||
DWORD n;
|
||||
HRESULT hres;
|
||||
int ret;
|
||||
|
||||
TRACE("%s\n", debugstr_variant(arg));
|
||||
|
||||
|
@ -551,19 +553,16 @@ static HRESULT Global_Hex(vbdisp_t *This, VARIANT *arg, unsigned args_cnt, VARIA
|
|||
case VT_I2:
|
||||
n = (WORD)V_I2(arg);
|
||||
break;
|
||||
case VT_I4:
|
||||
n = V_I4(arg);
|
||||
break;
|
||||
case VT_EMPTY:
|
||||
n = 0;
|
||||
break;
|
||||
case VT_NULL:
|
||||
if(res)
|
||||
V_VT(res) = VT_NULL;
|
||||
return S_OK;
|
||||
default:
|
||||
FIXME("unsupported type %s\n", debugstr_variant(arg));
|
||||
return E_NOTIMPL;
|
||||
hres = to_int(arg, &ret);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
else
|
||||
n = ret;
|
||||
}
|
||||
|
||||
buf[16] = 0;
|
||||
|
|
|
@ -233,10 +233,31 @@ TestHex -1, "FFFF"
|
|||
TestHex -16, "FFF0"
|
||||
TestHex -934859845, "C8472BBB"
|
||||
TestHex empty, "0"
|
||||
TestHex "17", "11"
|
||||
TestHex 228.5, "E4"
|
||||
TestHex -32767, "8001"
|
||||
TestHex -32768, "FFFF8000"
|
||||
TestHex 2147483647.49, "7FFFFFFF"
|
||||
TestHex -2147483647.5, "80000000"
|
||||
newObject.myval = 30.5
|
||||
TestHex newObject, "1E"
|
||||
newObject.myval = "27"
|
||||
TestHex newObject, "1B"
|
||||
|
||||
|
||||
Call ok(getVT(hex(null)) = "VT_NULL", "getVT(hex(null)) = " & getVT(hex(null)))
|
||||
Call ok(getVT(hex(empty)) = "VT_BSTR", "getVT(hex(empty)) = " & getVT(hex(empty)))
|
||||
|
||||
Sub TestHexError(num, err_num)
|
||||
On Error Resume Next
|
||||
Call Hex(num)
|
||||
Call ok(Err.number = err_num, "Hex(" & num & ") returns error number " & Err.number & " expected " & err_num)
|
||||
End Sub
|
||||
|
||||
TestHexError 2147483647.5, 6
|
||||
TestHexError 2147483648.51, 6
|
||||
TestHexError "test", 13
|
||||
|
||||
Sub TestOct(x, ex, res_type)
|
||||
Call ok(Oct(x) = ex, "Oct(" & x & ") = " & Oct(x) & " expected " & ex)
|
||||
Call ok(getVT(Oct(x)) = res_type, "getVT(Oct(" &x & ")) = " & getVT(Oct(x)) & "expected " & res_type)
|
||||
|
|
Loading…
Reference in New Issue