Skip to content

Upsert testing plan #4470

Open
Open
@dminor

Description

@dminor

Proposal: https://github.com/tc39/proposal-upsert
Rendered specification text: https://tc39.es/proposal-upsert/
Implementations: engine262, SpiderMonkey

Map.getOrInsert

  • Appending a new value normalizes -0 and +0
  • Appending new values
  • Appending new values with missing key
  • Throw a type error if this is a Set
  • Throw a type error if this is a WeakMap
  • Throw a type error if this is does not have a [[MapData]] slot
  • Verify properties of getOrInsert
  • Verify length of getOrInsert
  • Verify name of getOrInsert
  • Verify getOrInsert is not a constructor
  • Check return value when key is not present
  • Check return value when key is present
  • Check return value for normalized key
  • Throw a type error if this is not an Object

Map.getOrInsertComputed

  • Appending a new value normalizes -0 and +0
  • Appending new values
  • Appending new values with missing key
  • Check abrupt completion from callback function
  • Verify behaviour for callable callback function
  • Verify that callback function is not called if key is present
  • Verify that this is undefined and the callback receives exactly one argument
  • Throw a type error if this is a Set
  • Throw a type error if this is a WeakMap
  • Throw a type error if this is does not have a [[MapData]] slot
  • Verify properties of getOrInsertComputed
  • Verify length of getOrInsertComputed
  • Verify name of getOrInsertComputed
  • Verify getOrInsertComputed is not a constructor
  • Verify that a TypeError is thrown if callback function is not callable
  • Verify that a TypeError is thrown if callback function is not callable even when key is present
  • Verify that mutation of value corresponding to the key during callback function execution is overwritten
  • Verify state of the Map after getOrInsertComputed if the callback throws
  • Verify state of the Map after getOrInsertComputed if the callback mutates the Map and then throws
  • Map does not contain the key, but the callback inserts it, then returns a different value from the one it inserted
  • Check return value when key is not present
  • Check return value when key is present
  • Check return value for normalized key
  • Throw a type error if this is not an Object

WeakMap.getOrInsert

  • Add object key if key is not present in the map
  • Add symbol key if key is not present in the map
  • Throw TypeError if this does not have a [[WeakMapData]] slot
  • Verify properties of getOrInsert
  • Verify length of getOrInsert
  • Verify name of getOrInsert
  • Verify getOrInsert is not a constructor
  • Check return value when object key is not present
  • Check return value when symbol key is not present
  • Check return value when object key is present
  • Check return value when symbol key is present
  • Throw a type error if this is not an Object
  • Throw a type error if key is not weakly holdable

WeakMap.getOrInsertComputed

  • Add object key if key is not present in the map
  • Add symbol key if key is not present in the map
  • Appending new values with missing key
  • Check abrupt completion from callback function
  • Verify that callback function is not called if key is present
  • Verify that this is undefined and the callback receives exactly one argument
  • Throw TypeError if this does not have a [[WeakMapData]] slot
  • Verify properties of getOrInsertComputed
  • Verify length of getOrInsertComputed
  • Verify name of getOrInsertComputed
  • Verify getOrInsertComputed is not a constructor
  • Verify that a TypeError is thrown if callback function is not callable
  • Verify that a TypeError is thrown if callback function is not callable even when key is present
  • Verify that mutation of value corresponding to the key during callback function execution is overwritten
  • Verify state of the WeakMap after getOrInsertComputed if the callback throws
  • Verify state of the WeakMap after getOrInsertComputed if the callback mutates the WeakMap and then throws
  • Map does not contain the key, but the callback inserts it, then returns a different value from the one it inserted
  • Check return value when object key is not present
  • Check return value when symbol key is not present
  • Check return value when object key is present
  • Check return value when symbol key is present
  • Throw a type error if this is not an Object
  • Throw a type error if key is not weakly holdable

Metadata

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