mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-03 01:01:44 +00:00
vbscript: Coerce to VT_BOOL when evaluating jump conditions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
295d521b11
commit
0a7f5646e4
|
@ -413,43 +413,30 @@ static HRESULT stack_assume_val(exec_ctx_t *ctx, unsigned n)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static int stack_pop_bool(exec_ctx_t *ctx, BOOL *b)
|
||||
static HRESULT stack_pop_bool(exec_ctx_t *ctx, BOOL *b)
|
||||
{
|
||||
variant_val_t val;
|
||||
HRESULT hres;
|
||||
VARIANT_BOOL vb;
|
||||
VARIANT v;
|
||||
|
||||
hres = stack_pop_val(ctx, &val);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
switch (V_VT(val.v))
|
||||
if (V_VT(val.v) == VT_NULL)
|
||||
{
|
||||
case VT_BOOL:
|
||||
*b = V_BOOL(val.v);
|
||||
break;
|
||||
case VT_NULL:
|
||||
case VT_EMPTY:
|
||||
*b = FALSE;
|
||||
break;
|
||||
case VT_I2:
|
||||
*b = V_I2(val.v);
|
||||
break;
|
||||
case VT_I4:
|
||||
*b = V_I4(val.v);
|
||||
break;
|
||||
case VT_BSTR:
|
||||
hres = VarBoolFromStr(V_BSTR(val.v), ctx->script->lcid, 0, &vb);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
*b=vb;
|
||||
break;
|
||||
default:
|
||||
FIXME("unsupported for %s\n", debugstr_variant(val.v));
|
||||
release_val(&val);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
return S_OK;
|
||||
else
|
||||
{
|
||||
V_VT(&v) = VT_EMPTY;
|
||||
if (SUCCEEDED(hres = VariantChangeType(&v, val.v, VARIANT_LOCALBOOL, VT_BOOL)))
|
||||
*b = !!V_BOOL(&v);
|
||||
}
|
||||
|
||||
release_val(&val);
|
||||
|
||||
return hres;
|
||||
}
|
||||
|
||||
static HRESULT stack_pop_disp(exec_ctx_t *ctx, IDispatch **ret)
|
||||
|
|
|
@ -420,6 +420,69 @@ else
|
|||
end if
|
||||
Call ok(x = 1, "if ""-1"" not executed")
|
||||
|
||||
x = 0
|
||||
if 0.1 then
|
||||
x = 1
|
||||
else
|
||||
ok false, "if ""0.1"" else executed"
|
||||
end if
|
||||
Call ok(x = 1, "if ""0.1"" not executed")
|
||||
|
||||
x = 0
|
||||
if "TRUE" then
|
||||
x = 1
|
||||
else
|
||||
ok false, "if ""TRUE"" else executed"
|
||||
end if
|
||||
Call ok(x = 1, "if ""TRUE"" not executed")
|
||||
|
||||
x = 0
|
||||
if "#TRUE#" then
|
||||
x = 1
|
||||
else
|
||||
ok false, "if ""#TRUE#"" else executed"
|
||||
end if
|
||||
Call ok(x = 1, "if ""#TRUE#"" not executed")
|
||||
|
||||
x = 0
|
||||
if (not "#FALSE#") then
|
||||
x = 1
|
||||
else
|
||||
ok false, "if ""not #FALSE#"" else executed"
|
||||
end if
|
||||
Call ok(x = 1, "if ""not #FALSE#"" not executed")
|
||||
|
||||
Class ValClass
|
||||
Public myval
|
||||
|
||||
Public default Property Get defprop
|
||||
defprop = myval
|
||||
End Property
|
||||
End Class
|
||||
|
||||
Dim MyObject
|
||||
Set MyObject = New ValClass
|
||||
|
||||
MyObject.myval = 1
|
||||
Call ok(CBool(MyObject) = True, "CBool(MyObject) = " & CBool(MyObject))
|
||||
x = 0
|
||||
if MyObject then
|
||||
x = 1
|
||||
else
|
||||
ok false, "if ""MyObject(1)"" else executed"
|
||||
end if
|
||||
Call ok(x = 1, "if ""MyObject(1)"" not executed")
|
||||
|
||||
MyObject.myval = 0
|
||||
Call ok(CBool(MyObject) = False, "CBool(MyObject) = " & CBool(MyObject))
|
||||
x = 0
|
||||
if not MyObject then
|
||||
x = 1
|
||||
else
|
||||
ok false, "if ""MyObject(0)"" else executed"
|
||||
end if
|
||||
Call ok(x = 1, "if ""MyObject(0)"" not executed")
|
||||
|
||||
x = 0
|
||||
WHILE x < 3 : x = x + 1 : Wend
|
||||
Call ok(x = 3, "x not equal to 3")
|
||||
|
|
Loading…
Reference in a new issue