Skip to content

Commit

Permalink
fix bug in polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Apr 9, 2024
1 parent f4286d0 commit 29659b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion polyfill/polyfill.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function sum(iterable) {
}
if (!Object.is(value, -0)) {
if (!Number.isFinite(value)) {
return drainNonFiniteValue(val);
return drainNonFiniteValue(value);
}
partials.push(value);
break;
Expand Down
3 changes: 3 additions & 0 deletions polyfill/test-polyfill.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ test('special cases', t => {
assert.strictEqual(mathSum([-0, -0, -0, 0]), 0);
assert.strictEqual(mathSum([1, Infinity, -1e308]), Infinity);
assert.strictEqual(mathSum([1, Infinity, -1e308, -Infinity]), NaN);
assert.strictEqual(mathSum([Infinity]), Infinity);
assert.strictEqual(mathSum([-Infinity]), -Infinity);
assert.strictEqual(mathSum([-Infinity, Infinity]), NaN);
});

test('1, 2 element lists', t => {
Expand Down

0 comments on commit 29659b9

Please sign in to comment.