Commit db137cc9 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

jscript: Make Array.join generic.

parent 6f618936
......@@ -342,20 +342,18 @@ static HRESULT array_join(script_ctx_t *ctx, DispatchEx *array, DWORD length, co
}
/* ECMA-262 3rd Edition 15.4.4.5 */
static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPARAMS *dp,
static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, DISPPARAMS *dp,
VARIANT *retv, jsexcept_t *ei, IServiceProvider *caller)
{
DispatchEx *jsthis;
DWORD length;
HRESULT hres;
TRACE("\n");
if(is_vclass(jsthis, JSCLASS_ARRAY)) {
length = array_from_vdisp(jsthis)->length;
}else {
FIXME("dispid is not Array\n");
return E_NOTIMPL;
}
hres = get_length(ctx, vthis, ei, &jsthis, &length);
if(FAILED(hres))
return hres;
if(arg_cnt(dp)) {
BSTR sep;
......@@ -364,11 +362,11 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
if(FAILED(hres))
return hres;
hres = array_join(ctx, jsthis->u.jsdisp, length, sep, retv, ei, caller);
hres = array_join(ctx, jsthis, length, sep, retv, ei, caller);
SysFreeString(sep);
}else {
hres = array_join(ctx, jsthis->u.jsdisp, length, default_separatorW, retv, ei, caller);
hres = array_join(ctx, jsthis, length, default_separatorW, retv, ei, caller);
}
return hres;
......
......@@ -654,6 +654,16 @@ ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
tmp = arr.toString("test");
ok(tmp === "1,2,,false,,,a", "arr.toString() = " + tmp);
arr = new Object();
arr.length = 3;
arr[0] = "aa";
arr[2] = 2;
arr[7] = 3;
arr.join = Array.prototype.join;
tmp = arr.join(",");
ok(arr.length === 3, "arr.length = " + arr.length);
ok(tmp === "aa,,2", "tmp = " + tmp);
arr = [5,true,2,-1,3,false,"2.5"];
tmp = arr.sort(function(x,y) { return y-x; });
ok(tmp === arr, "tmp !== arr");
......@@ -1880,6 +1890,7 @@ testArrayHostThis("slice");
testArrayHostThis("splice");
testArrayHostThis("unshift");
testArrayHostThis("reverse");
testArrayHostThis("join");
function testObjectInherit(obj, constr, ts, tls, vo) {
ok(obj instanceof Object, "obj is not instance of Object");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment