Math.sumPrecise testing plan

Open
#4,054 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
testing-qa

Research direction

Use the Math.sumPrecise checklist in this issue as the scope. First locate the existing test262 tests for Math.sumPrecise and follow their harness and naming conventions, then cover the unchecked boilerplate, success, failure, and iterator-observation cases. Done means the listed cases are represented and the relevant test262 tests pass.

Written by the indexing model from the issue text.

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
Dominant language
JavaScript
Stars
2.9k
Forks
571
Avg merge
1d 22h
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tc39/test262

All issues in tc39/test262

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.