Skip to content

Commit

Permalink
test: add else and error case for TextDecoder
Browse files Browse the repository at this point in the history
add test for tinyurl.com/codeandlearn-encoding-1
add test for tinyurl.com/codeandlearn-encoding-2

PR-URL: #24162
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Lauri Piisang authored and BridgeAR committed Nov 13, 2018
1 parent e5e9c64 commit 77163a9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/parallel/test-whatwg-encoding-textdecoder-fatal.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,15 @@ bad.forEach((t) => {
assert(!new TextDecoder().fatal);
assert(new TextDecoder('utf-8', { fatal: true }).fatal);
}

{
const notArrayBufferViewExamples = [false, {}, 1, '', new Error()];
notArrayBufferViewExamples.forEach((invalidInputType) => {
common.expectsError(() => {
new TextDecoder(undefined, null).decode(invalidInputType);
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
});
}
8 changes: 8 additions & 0 deletions test/parallel/test-whatwg-encoding-textdecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ if (common.hasIntl) {
});
}

// Test TextDecoder, label undefined, options null
{
const dec = new TextDecoder(undefined, null);
assert.strictEqual(dec.encoding, 'utf-8');
assert.strictEqual(dec.fatal, false);
assert.strictEqual(dec.ignoreBOM, false);
}

// Test TextDecoder, UTF-16le
{
const dec = new TextDecoder('utf-16le');
Expand Down

0 comments on commit 77163a9

Please sign in to comment.