Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,50 @@ impl TypedArrayPrototype {
Ok(find_rec.1)
}

// ### 23.2.3.14 %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] )(https://tc39.es/ecma262/multipage/indexed-collections.html#sec-%typedarray%.prototype.findlastindex)
// The interpretation and use of the arguments of this method are the same as for Array.prototype.findLastIndex as defined in 23.1.3.12.
fn find_last_index<'gc>(
_agent: &mut Agent,
_this_value: Value,
_: ArgumentsList,
_gc: GcScope<'gc, '_>,
agent: &mut Agent,
this_value: Value,
arguments: ArgumentsList,
gc: GcScope<'gc, '_>,
) -> JsResult<Value<'gc>> {
todo!()
let this_value = this_value.bind(gc.nogc());
let predicate = arguments.get(0).scope(agent, gc.nogc());
let this_arg = arguments.get(1).scope(agent, gc.nogc());
// 1. Let O be the this value.
let o = this_value;
// 2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
let ta_record = validate_typed_array(agent, o, Ordering::SeqCst, gc.nogc())?;
let o = ta_record.object;
// 3. Let len be TypedArrayLength(taRecord).
let len = match o {
TypedArray::Int8Array(_)
| TypedArray::Uint8Array(_)
| TypedArray::Uint8ClampedArray(_) => {
typed_array_length::<u8>(agent, &ta_record, gc.nogc())
}
TypedArray::Int16Array(_) | TypedArray::Uint16Array(_) => {
typed_array_length::<u16>(agent, &ta_record, gc.nogc())
}
#[cfg(feature = "proposal-float16array")]
TypedArray::Float16Array(_) => typed_array_length::<f16>(agent, &ta_record, gc.nogc()),
TypedArray::Int32Array(_)
| TypedArray::Uint32Array(_)
| TypedArray::Float32Array(_) => {
typed_array_length::<u32>(agent, &ta_record, gc.nogc())
}
TypedArray::BigInt64Array(_)
| TypedArray::BigUint64Array(_)
| TypedArray::Float64Array(_) => {
typed_array_length::<u64>(agent, &ta_record, gc.nogc())
}
} as i64;
let o = o.into_object().scope(agent, gc.nogc());
// 4. Let findRec be ? FindViaPredicate(O, len, descending, predicate, thisArg).
let find_rec = find_via_predicate(agent, o, len, false, predicate, this_arg, gc)?;
// 5. Return findRec.[[Index]].
Ok(Number::try_from(find_rec.0).unwrap().into_value())
}

// ### [ 23.2.3.15 %TypedArray%.prototype.forEach ( callback [ , thisArg ] )](https://tc39.es/ecma262/multipage/indexed-collections.html#sec-%typedarray%.prototype.foreach)
Expand Down
34 changes: 0 additions & 34 deletions tests/expectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -9570,40 +9570,6 @@
"built-ins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js": "CRASH",
"built-ins/TypedArray/prototype/filter/values-are-not-cached.js": "CRASH",
"built-ins/TypedArray/prototype/filter/values-are-set.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/callbackfn-resize.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/detached-buffer.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/invoked-as-func.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/invoked-as-method.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/resizable-buffer.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/this-is-not-object.js": "CRASH",
"built-ins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js": "CRASH",
"built-ins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js": "CRASH",
"built-ins/TypedArray/prototype/join/coerced-separator-shrink.js": "CRASH",
"built-ins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js": "CRASH",
Expand Down
6 changes: 3 additions & 3 deletions tests/metrics.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"results": {
"crash": 13036,
"fail": 7714,
"pass": 25986,
"crash": 13000,
"fail": 7716,
"pass": 26020,
"skip": 65,
"timeout": 0,
"unresolved": 0
Expand Down