MCPcopy
hub / github.com/immutable-js/immutable-js / expectAllUndefined

Function expectAllUndefined

__tests__/List.ts:944–963  ·  view source on GitHub ↗
(list: List<number | undefined>, size: number)

Source from the content-addressed store, hash-verified

942 // every read path: get, toArray, the values iterator (both directions),
943 // forEach, and the structural equals / hashCode.
944 function expectAllUndefined(list: List<number | undefined>, size: number) {
945 const expected = List<number | undefined>(
946 new Array(size).fill(undefined)
947 );
948
949 expect(list.size).toBe(size);
950 for (let i = 0; i < size; i++) {
951 expect(list.get(i)).toBeUndefined();
952 }
953 expect(list.toArray()).toEqual(new Array(size).fill(undefined));
954 expect([...list.values()]).toEqual(new Array(size).fill(undefined));
955 expect([...list.toSeq().reverse().values()]).toEqual(
956 new Array(size).fill(undefined)
957 );
958 list.forEach((value) => expect(value).toBeUndefined());
959 // @ts-expect-error null should not be here
960 expect(list.includes(null)).toBe(false);
961 expect(list.equals(expected)).toBe(true);
962 expect(list.hashCode()).toBe(expected.hashCode());
963 }
964
965 it('setSize(32).setSize(33) — minimal repro', () => {
966 expectAllUndefined(

Callers 1

List.tsFile · 0.85

Calls 10

ListInterface · 0.90
valuesMethod · 0.80
forEachMethod · 0.80
getMethod · 0.65
toArrayMethod · 0.65
reverseMethod · 0.65
toSeqMethod · 0.65
includesMethod · 0.65
equalsMethod · 0.65
hashCodeMethod · 0.65

Tested by

no test coverage detected