jscript: Added throw statement implementation.
This commit is contained in:
parent
66eb62ada6
commit
e7903ecfa9
|
@ -722,10 +722,27 @@ HRESULT switch_statement_eval(exec_ctx_t *ctx, statement_t *stat, return_type_t
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 12.13 */
|
||||
HRESULT throw_statement_eval(exec_ctx_t *ctx, statement_t *_stat, return_type_t *rt, VARIANT *ret)
|
||||
{
|
||||
FIXME("\n");
|
||||
return E_NOTIMPL;
|
||||
expression_statement_t *stat = (expression_statement_t*)_stat;
|
||||
exprval_t exprval;
|
||||
VARIANT val;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
hres = expr_eval(ctx, stat->expr, 0, &rt->ei, &exprval);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = exprval_to_value(ctx->parser->script, &exprval, &rt->ei, &val);
|
||||
exprval_release(&exprval);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
rt->ei.var = val;
|
||||
return DISP_E_EXCEPTION;
|
||||
}
|
||||
|
||||
/* ECMA-262 3rd Edition 12.14 */
|
||||
|
|
|
@ -267,4 +267,80 @@ try {
|
|||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
||||
var state = "";
|
||||
try {
|
||||
ok(state === "", "try: state = " + state);
|
||||
state = "try";
|
||||
throw "except";
|
||||
}catch(ex) {
|
||||
ok(state === "try", "catch: state = " + state);
|
||||
ok(ex === "except", "ex is not \"except\"");
|
||||
state = "catch";
|
||||
}
|
||||
ok(state === "catch", "state = " + state + " expected catch");
|
||||
|
||||
var state = "";
|
||||
try {
|
||||
ok(state === "", "try: state = " + state);
|
||||
state = "try";
|
||||
throw true;
|
||||
}catch(ex) {
|
||||
ok(state === "try", "catch: state = " + state);
|
||||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
||||
var state = "";
|
||||
try {
|
||||
ok(state === "", "try: state = " + state);
|
||||
state = "try";
|
||||
try { throw true; } finally {}
|
||||
}catch(ex) {
|
||||
ok(state === "try", "catch: state = " + state);
|
||||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
||||
var state = "";
|
||||
try {
|
||||
ok(state === "", "try: state = " + state);
|
||||
state = "try";
|
||||
try { throw "except"; } catch(ex) { throw true; }
|
||||
}catch(ex) {
|
||||
ok(state === "try", "catch: state = " + state);
|
||||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
||||
function throwFunc(x) {
|
||||
throw x;
|
||||
}
|
||||
|
||||
var state = "";
|
||||
try {
|
||||
ok(state === "", "try: state = " + state);
|
||||
state = "try";
|
||||
throwFunc(true);
|
||||
}catch(ex) {
|
||||
ok(state === "try", "catch: state = " + state);
|
||||
ok(ex === true, "ex is not true");
|
||||
state = "catch";
|
||||
}finally {
|
||||
ok(state === "catch", "funally: state = " + state);
|
||||
state = "finally";
|
||||
}
|
||||
ok(state === "finally", "state = " + state + " expected finally");
|
||||
|
||||
reportSuccess();
|
||||
|
|
Loading…
Reference in New Issue