jscript: Added Math.PI implementation.
This commit is contained in:
parent
f82df0ac63
commit
0e8bcbd9de
|
@ -54,6 +54,21 @@ static const WCHAR sinW[] = {'s','i','n',0};
|
|||
static const WCHAR sqrtW[] = {'s','q','r','t',0};
|
||||
static const WCHAR tanW[] = {'t','a','n',0};
|
||||
|
||||
static HRESULT math_constant(DOUBLE val, WORD flags, VARIANT *retv)
|
||||
{
|
||||
switch(flags) {
|
||||
case DISPATCH_PROPERTYGET:
|
||||
V_VT(retv) = VT_R8;
|
||||
V_R8(retv) = val;
|
||||
return S_OK;
|
||||
case DISPATCH_PROPERTYPUT:
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
FIXME("unhandled flags %x\n", flags);
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT Math_E(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
||||
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
|
||||
{
|
||||
|
@ -89,11 +104,12 @@ static HRESULT Math_LN10(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 15.8.1.6 */
|
||||
static HRESULT Math_PI(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
||||
VARIANT *retv, jsexcept_t *ei, IServiceProvider *sp)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
TRACE("\n");
|
||||
return math_constant(M_PI, flags, retv);
|
||||
}
|
||||
|
||||
static HRESULT Math_SQRT2(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp,
|
||||
|
|
|
@ -609,4 +609,9 @@ date = new Date(100);
|
|||
ok(date.getTime() === 100, "date.getTime() = " + date.getTime());
|
||||
ok(Date.prototype.getTime() === 0, "date.prototype.getTime() = " + Date.prototype.getTime());
|
||||
|
||||
ok(typeof(Math.PI) === "number", "typeof(Math.PI) = " + typeof(Math.PI));
|
||||
ok(Math.floor(Math.PI*100) === 314, "Math.PI = " + Math.PI);
|
||||
Math.PI = "test";
|
||||
ok(Math.floor(Math.PI*100) === 314, "modified Math.PI = " + Math.PI);
|
||||
|
||||
reportSuccess();
|
||||
|
|
Loading…
Reference in New Issue