Skip to content

Math.sumPrecise testing plan #4054

Open

Description

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 getting length

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions