jscript: Added initial prototype of functions.

This commit is contained in:
Jacek Caban 2008-09-10 21:09:04 +02:00 committed by Alexandre Julliard
parent b2a93fe3c3
commit 0c6b804e63
2 changed files with 30 additions and 1 deletions

View File

@ -424,11 +424,17 @@ HRESULT create_source_function(parser_ctx_t *ctx, parameter_t *parameters, sourc
scope_chain_t *scope_chain, DispatchEx **ret)
{
FunctionInstance *function;
DispatchEx *prototype;
parameter_t *iter;
DWORD length = 0;
HRESULT hres;
hres = create_function(ctx->script, PROPF_CONSTR, NULL, &function);
hres = create_object(ctx->script, NULL, &prototype);
if(FAILED(hres))
return hres;
hres = create_function(ctx->script, PROPF_CONSTR, prototype, &function);
jsdisp_release(prototype);
if(FAILED(hres))
return hres;

View File

@ -93,4 +93,27 @@ obj1.func = function () {
ok(obj1.func(true) === "test", "obj1.func(true) is not \"test\"");
function testConstr1() {
this.var1 = 1;
ok(this !== undefined, "this is undefined");
ok(arguments.length === 1, "arguments.length is not 1");
ok(arguments["0"] === true, "arguments[0] is not 1");
return false;
}
testConstr1.prototype.pvar = 1;
var obj2 = new testConstr1(true);
ok(typeof(obj2) === "object", "typeof(obj2) is not object");
ok(obj2.pvar === 1, "obj2.pvar is not 1");
testConstr1.prototype.pvar = 2;
ok(obj2.pvar === 2, "obj2.pvar is not 2");
obj2.pvar = 3;
testConstr1.prototype.pvar = 1;
ok(obj2.pvar === 3, "obj2.pvar is not 3");
reportSuccess();