Skip to content

Commit 30f1ff2

Browse files
committedDec 10, 2023
Implement TypedArray.prototype.toSorted
1 parent 05f00a8 commit 30f1ff2

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed
 

‎quickjs.c

+19
Original file line numberDiff line numberDiff line change
@@ -49562,6 +49562,24 @@ static JSValue js_typed_array_sort(JSContext *ctx, JSValue this_val,
4956249562
return js_dup(this_val);
4956349563
}
4956449564

49565+
static JSValue js_typed_array_toSorted(JSContext *ctx, JSValue this_val,
49566+
int argc, JSValue *argv)
49567+
{
49568+
JSValue arr, ret;
49569+
JSObject *p;
49570+
49571+
p = get_typed_array(ctx, this_val, /*is_dataview*/0);
49572+
if (!p)
49573+
return JS_EXCEPTION;
49574+
arr = js_typed_array_constructor_ta(ctx, JS_UNDEFINED, this_val,
49575+
p->class_id);
49576+
if (JS_IsException(arr))
49577+
return JS_EXCEPTION;
49578+
ret = js_typed_array_sort(ctx, arr, argc, argv);
49579+
JS_FreeValue(ctx, arr);
49580+
return ret;
49581+
}
49582+
4956549583
static const JSCFunctionListEntry js_typed_array_base_funcs[] = {
4956649584
JS_CFUNC_DEF("from", 1, js_typed_array_from ),
4956749585
JS_CFUNC_DEF("of", 0, js_typed_array_of ),
@@ -49598,6 +49616,7 @@ static const JSCFunctionListEntry js_typed_array_base_proto_funcs[] = {
4959849616
JS_CFUNC_DEF("slice", 2, js_typed_array_slice ),
4959949617
JS_CFUNC_DEF("subarray", 2, js_typed_array_subarray ),
4960049618
JS_CFUNC_DEF("sort", 1, js_typed_array_sort ),
49619+
JS_CFUNC_DEF("toSorted", 1, js_typed_array_toSorted ),
4960149620
JS_CFUNC_MAGIC_DEF("join", 1, js_typed_array_join, 0 ),
4960249621
JS_CFUNC_MAGIC_DEF("toLocaleString", 0, js_typed_array_join, 1 ),
4960349622
JS_CFUNC_MAGIC_DEF("indexOf", 1, js_typed_array_indexOf, special_indexOf ),

‎test262_errors.txt

-14
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,6 @@ test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-
77
test262/test/built-ins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js:30: strict mode: TypeError: out-of-bound numeric index (Testing with Float64Array.)
88
test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js:30: TypeError: ArrayBuffer is detached (Testing with Float64Array.)
99
test262/test/built-ins/TypedArray/prototype/sort/sort-tonumber.js:30: strict mode: TypeError: ArrayBuffer is detached (Testing with Float64Array.)
10-
test262/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js:26: TypeError: not a function (Testing with Float64Array.)
11-
test262/test/built-ins/TypedArray/prototype/toSorted/ignores-species.js:26: strict mode: TypeError: not a function (Testing with Float64Array.)
12-
test262/test/built-ins/TypedArray/prototype/toSorted/immutable.js:14: TypeError: not a function (Testing with Float64Array.)
13-
test262/test/built-ins/TypedArray/prototype/toSorted/immutable.js:14: strict mode: TypeError: not a function (Testing with Float64Array.)
14-
test262/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js:21: TypeError: not a function (Testing with Float64Array.)
15-
test262/test/built-ins/TypedArray/prototype/toSorted/length-property-ignored.js:21: strict mode: TypeError: not a function (Testing with Float64Array.)
16-
test262/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js:30: TypeError: cannot convert to object
17-
test262/test/built-ins/TypedArray/prototype/toSorted/metadata/length.js:30: strict mode: TypeError: cannot convert to object
18-
test262/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js:28: TypeError: cannot convert to object
19-
test262/test/built-ins/TypedArray/prototype/toSorted/metadata/name.js:28: strict mode: TypeError: cannot convert to object
20-
test262/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js:18: Test262Error: typeof Expected SameValue(«undefined», «function») to be true
21-
test262/test/built-ins/TypedArray/prototype/toSorted/metadata/property-descriptor.js:18: strict mode: Test262Error: typeof Expected SameValue(«undefined», «function») to be true
22-
test262/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js:25: Test262Error: isConstructor invoked with a non-function value
23-
test262/test/built-ins/TypedArray/prototype/toSorted/not-a-constructor.js:25: strict mode: Test262Error: isConstructor invoked with a non-function value
2410
test262/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js:29: TypeError: not a function (Testing with BigInt64Array.)
2511
test262/test/built-ins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js:29: strict mode: TypeError: not a function (Testing with BigInt64Array.)
2612
test262/test/built-ins/TypedArray/prototype/with/early-type-coercion.js:29: TypeError: not a function (Testing with Float64Array.)

0 commit comments

Comments
 (0)