Skip to content

Commit

Permalink
fix(ecmascript): Wrong assert in some Array methods (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
yossydev authored Feb 13, 2025
1 parent 529e860 commit 61ab8f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,9 @@ impl ArrayPrototype {
// 4. Let n be ? ToIntegerOrInfinity(fromIndex).
let n = to_integer_or_infinity(agent, from_index, gc.reborrow())?;
// 5. Assert: If fromIndex is undefined, then n is 0.
assert_eq!(from_index.is_undefined(), n.into_i64() == 0);
if from_index.is_undefined() {
assert_eq!(n.into_i64(), 0);
}
// 6. If n = +∞, return false.
let n = if n.is_pos_infinity() {
return Ok(false.into());
Expand Down Expand Up @@ -1477,7 +1479,9 @@ impl ArrayPrototype {
// 4. Let n be ? ToIntegerOrInfinity(fromIndex).
let n = to_integer_or_infinity(agent, from_index, gc.reborrow())?;
// 5. Assert: If fromIndex is undefined, then n is 0.
assert_eq!(from_index.is_undefined(), n.into_i64() == 0);
if from_index.is_undefined() {
assert_eq!(n.into_i64(), 0);
}
// 6. If n = +∞, return -1𝔽.
let n = if n.is_pos_infinity() {
return Ok((-1).into());
Expand Down
18 changes: 0 additions & 18 deletions tests/expectations.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,28 +242,13 @@
"built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js": "FAIL",
"built-ins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js": "FAIL",
"built-ins/Array/prototype/forEach/resizable-buffer.js": "CRASH",
"built-ins/Array/prototype/includes/coerced-searchelement-fromindex-resize.js": "CRASH",
"built-ins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js": "CRASH",
"built-ins/Array/prototype/includes/fromIndex-minus-zero.js": "CRASH",
"built-ins/Array/prototype/includes/resizable-buffer.js": "CRASH",
"built-ins/Array/prototype/includes/tointeger-fromindex.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-1-11.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-1-12.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-5-1.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-5-14.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-5-2.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-5-26.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-5-27.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-5-3.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-5-5.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-5-9.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-6-1.js": "CRASH",
"built-ins/Array/prototype/indexOf/15.4.4.14-9-a-19.js": "FAIL",
"built-ins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js": "FAIL",
"built-ins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js": "CRASH",
"built-ins/Array/prototype/indexOf/coerced-searchelement-fromindex-grow.js": "CRASH",
"built-ins/Array/prototype/indexOf/coerced-searchelement-fromindex-shrink.js": "CRASH",
"built-ins/Array/prototype/indexOf/fromindex-zero-conversion.js": "CRASH",
"built-ins/Array/prototype/indexOf/resizable-buffer.js": "CRASH",
"built-ins/Array/prototype/join/S15.4.4.5_A3.1_T2.js": "FAIL",
"built-ins/Array/prototype/join/resizable-buffer.js": "CRASH",
Expand Down Expand Up @@ -21542,9 +21527,6 @@
"staging/sm/Array/from_this.js": "CRASH",
"staging/sm/Array/frozen-dense-array.js": "FAIL",
"staging/sm/Array/group.js": "CRASH",
"staging/sm/Array/includes-trailing-holes.js": "CRASH",
"staging/sm/Array/indexOf-never-returns-negative-zero.js": "CRASH",
"staging/sm/Array/indexOf-packed-array.js": "CRASH",
"staging/sm/Array/isArray.js": "FAIL",
"staging/sm/Array/length-01.js": "FAIL",
"staging/sm/Array/length-nonwritable-redefine-nop.js": "FAIL",
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": 13145,
"fail": 9052,
"pass": 24539,
"crash": 13120,
"fail": 9059,
"pass": 24557,
"skip": 65,
"timeout": 0,
"unresolved": 0
Expand Down

0 comments on commit 61ab8f8

Please sign in to comment.