Commit 1fc2896c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added VT_R8 support to to_int.

parent 5c211059
......@@ -125,6 +125,15 @@ static HRESULT to_int(VARIANT *v, int *ret)
case VT_I4:
*ret = V_I4(v);
break;
case VT_R8: {
double n = round(V_R8(v));
if(!is_int32(n)) {
FIXME("%lf is out of int range\n", n);
return E_FAIL;
}
*ret = n;
break;
}
default:
FIXME("not supported %s\n", debugstr_variant(v));
return E_NOTIMPL;
......
......@@ -124,6 +124,15 @@ Call ok(isNull(x), "InStr returned " & x)
x = InStr(2, null, "abcd")
Call ok(isNull(x), "InStr returned " & x)
x = InStr(1.3, "abcd", "bc")
Call ok(x = 2, "InStr returned " & x)
x = InStr(2.3, "abcd", "bc")
Call ok(x = 2, "InStr returned " & x)
x = InStr(2.6, "abcd", "bc")
Call ok(x = 0, "InStr returned " & x)
Sub TestMid(str, start, len, ex)
x = Mid(str, start, len)
Call ok(x = ex, "Mid(" & str & ", " & start & ", " & len & ") = " & x & " expected " & ex)
......@@ -182,6 +191,9 @@ Call ok(Len(empty) = 0, "Len(empty) = " & Len(empty))
Call ok(Space(1) = " ", "Space(1) = " & Space(1) & """")
Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
Call ok(Space(5) = " ", "Space(5) = " & Space(5) & """")
Call ok(Space(5.2) = " ", "Space(5.2) = " & Space(5.2) & """")
Call ok(Space(5.8) = " ", "Space(5.8) = " & Space(5.8) & """")
Call ok(Space(5.5) = " ", "Space(5.5) = " & Space(5.5) & """")
Sub TestRound(val, exval, vt)
Call ok(Round(val) = exval, "Round(" & val & ") = " & Round(val))
......
......@@ -343,6 +343,19 @@ TID_LIST
HRESULT get_typeinfo(tid_t,ITypeInfo**) DECLSPEC_HIDDEN;
#ifndef INT32_MIN
#define INT32_MIN (-2147483647-1)
#endif
#ifndef INT32_MAX
#define INT32_MAX (2147483647)
#endif
static inline BOOL is_int32(double d)
{
return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
}
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
......
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