vbscript: Added VT_R8 support to to_int.
This commit is contained in:
parent
5c211059a0
commit
1fc2896c7c
|
@ -125,6 +125,15 @@ static HRESULT to_int(VARIANT *v, int *ret)
|
||||||
case VT_I4:
|
case VT_I4:
|
||||||
*ret = V_I4(v);
|
*ret = V_I4(v);
|
||||||
break;
|
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:
|
default:
|
||||||
FIXME("not supported %s\n", debugstr_variant(v));
|
FIXME("not supported %s\n", debugstr_variant(v));
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
|
|
|
@ -124,6 +124,15 @@ Call ok(isNull(x), "InStr returned " & x)
|
||||||
x = InStr(2, null, "abcd")
|
x = InStr(2, null, "abcd")
|
||||||
Call ok(isNull(x), "InStr returned " & x)
|
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)
|
Sub TestMid(str, start, len, ex)
|
||||||
x = Mid(str, start, len)
|
x = Mid(str, start, len)
|
||||||
Call ok(x = ex, "Mid(" & str & ", " & start & ", " & len & ") = " & x & " expected " & ex)
|
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(1) = " ", "Space(1) = " & Space(1) & """")
|
||||||
Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
|
Call ok(Space(0) = "", "Space(0) = " & Space(0) & """")
|
||||||
Call ok(Space(5) = " ", "Space(5) = " & Space(5) & """")
|
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)
|
Sub TestRound(val, exval, vt)
|
||||||
Call ok(Round(val) = exval, "Round(" & val & ") = " & Round(val))
|
Call ok(Round(val) = exval, "Round(" & val & ") = " & Round(val))
|
||||||
|
|
|
@ -343,6 +343,19 @@ TID_LIST
|
||||||
|
|
||||||
HRESULT get_typeinfo(tid_t,ITypeInfo**) DECLSPEC_HIDDEN;
|
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;
|
HRESULT WINAPI VBScriptFactory_CreateInstance(IClassFactory*,IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
|
const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue