Skip to content

Commit 8d8d08b

Browse files
committed
test: ignore unreachable guards from coverage
1 parent e69d089 commit 8d8d08b

8 files changed

Lines changed: 9 additions & 3 deletions

File tree

base58.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function fromBase58core(str, alphabet, codes, format = 'uint8') {
207207
}
208208

209209
at = k + 1
210-
if (c !== 0 || at < zeros) throw new Error('Unexpected') // unreachable
210+
if (c !== 0 || at < zeros) /* c8 ignore next */ throw new Error('Unexpected') // unreachable
211211
}
212212
}
213213

fallback/_utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ function shouldSkipBuiltins() {
4747
return /firefox/i.test(g.navigator.userAgent || '') // as simple as we can
4848
}
4949

50+
/* c8 ignore next */
5051
return false // eslint-disable-line no-unreachable
5152
}
5253

fallback/encoding.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export class TextDecoder {
163163
return u.byteLength >= 2 && u[0] === 0xfe && u[1] === 0xff ? 2 : 0
164164
}
165165

166+
/* c8 ignore next */
166167
throw new Error('Unreachable')
167168
}
168169
}

fallback/multi-byte.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ export function multibyteEncoder(enc, onError) {
791791
throw new TypeError(E_STRICT)
792792
}
793793

794-
if (!map || map.length < size) throw new Error('Unreachable') // Important for perf
794+
if (!map || map.length < size) /* c8 ignore next */ throw new Error('Unreachable') // Important for perf
795+
795796
if (enc === 'gb18030') {
796797
// Deduping this branch hurts other encoders perf
797798
const encode = (cp) => {

fallback/utf8.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export function encode(string, loose) {
191191

192192
if (small) {
193193
// TODO: use resizable array buffers? will have to return a non-resizeable one
194-
if (p !== i) throw new Error('Unreachable') // Here, p === i (only when small is still true)
194+
if (p !== i) /* c8 ignore next */ throw new Error('Unreachable') // Here, p === i (only when small is still true)
195195
const bytesNew = new Uint8Array(p + (length - i) * 3) // maximium can be 3x of the string length in charcodes
196196
bytesNew.set(bytes)
197197
bytes = bytesNew

utf16.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function encode(str, loose = false, format = 'uint16') {
3434

3535
if (format === 'uint8-le' || format === 'uint8-be') return to8(u16) // Already swapped
3636
if (format === 'uint16') return u16
37+
/* c8 ignore next */
3738
throw new Error('Unreachable')
3839
}
3940

utf16.node.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function encode(str, loose = false, format = 'uint16') {
3030
return new Uint16Array(b.buffer, b.byteOffset, b.byteLength / 2)
3131
}
3232

33+
/* c8 ignore next */
3334
throw new Error('Unreachable')
3435
}
3536

utf32.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function encode(str, loose = false, format = 'uint32') {
1919
return u8
2020
}
2121

22+
/* c8 ignore next */
2223
throw new Error('Unreachable')
2324
}
2425

0 commit comments

Comments
 (0)