Open
Description
openedon Apr 12, 2024
Boilerplate
- Property descriptor
- Function length
- Function name
- Is not a constructor
- prototype is Function.prototype
- is extensible
Success cases
- Sum of finite numbers (same sign, mixed signs)
- Sum of one number is that number (negative, -0, 0, positive, NaN, ∞, -∞)
- Sum of empty is -0
- Sum of finite numbers with infinite result (∞, -∞)
- Sum of multiple numbers including any NaN is NaN
- Sum including any ∞ and no NaN or -∞ is ∞
- Sum including any -∞ and no NaN or ∞ is -∞
- Sum of ∞ and -∞ is NaN
- Sum of multiple -0 is -0
- Sum of multiple 0 is 0
- Sum of -0 and 0 is 0
- Sum of a non-array iterable works like sum of an array
- Sum of an empty non-array iterable is -0
Failure cases
- rejects non-Number values in iterable (Boolean, String, Symbol, BigInt, Object, null, undefined)
Other edge cases
- Not passing an argument throws TypeError
- summing each type of primitive throws TypeError
- summing a non-iterable object throws TypeError
- iterable yields more than 2⁵³ items (probably not testable)
- A case where sumPrecise disagrees with naive sum via reduce
- Order of observable operations
- iterator is closed (
return
is called) after yielding a non-Number - an Object value in the iterable does not have its
valueOf
,toString
, or[Symbol.toPrimitive]
methods called - iterator is still exhausted after the sum has reached the NaN or ±∞ states
- array is iterated via its
[Symbol.iterator]
method, not by gettinglength
Metadata
Assignees
Labels
No labels
Activity