Skip to content

Commit

Permalink
test: fix textdecoder test for small-icu builds
Browse files Browse the repository at this point in the history
The `Shift_JIS` encoding may not be available, e.g. when Node.js is
configured with `--with-intl=small-icu`.

PR-URL: #45225
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
  • Loading branch information
richardlau committed Nov 24, 2022
1 parent 38202d3 commit 42e9d80
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions test/parallel/test-whatwg-encoding-custom-textdecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,13 @@ if (common.hasIntl) {
}

if (common.hasIntl) {
const decoder = new TextDecoder('Shift_JIS');
const chunk = new Uint8Array([-1]);
const str = decoder.decode(chunk);
assert.strictEqual(str, '\ufffd');
try {
const decoder = new TextDecoder('Shift_JIS');
const chunk = new Uint8Array([-1]);
const str = decoder.decode(chunk);
assert.strictEqual(str, '\ufffd');
} catch (e) {
// Encoding may not be available, e.g. small-icu builds
assert.strictEqual(e.code, 'ERR_ENCODING_NOT_SUPPORTED');
}
}

0 comments on commit 42e9d80

Please sign in to comment.