util: throw if unreachable TypedArray checking code is reached

If a comparison code path that is supposed to be unreachable is reached,
throw. Add a c8 comment to ignore coverage for the line, as it
should be unreachable.

PR-URL: https://github.com/nodejs/node/pull/31737
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Rich Trott
2020-02-11 01:31:25 -10:00
committed by Anna Henningsen
parent 481fa1ca98
commit a18b437e6a

View File

@@ -147,7 +147,11 @@ function isIdenticalTypedArrayType(a, b) {
return check(b);
}
}
return false;
/* c8 ignore next */
assert.fail(
`Unknown TypedArray type checking ${a[SymbolToStringTag]} ${a}\n` +
`and ${b[SymbolToStringTag]} ${b}`
);
}
// Notes: Type tags are historical [[Class]] properties that can be set by