11cb0ef41Sopenharmony_ci// META: global=window,worker
21cb0ef41Sopenharmony_ci// META: script=resources/readable-stream-from-array.js
31cb0ef41Sopenharmony_ci// META: script=resources/readable-stream-to-array.js
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci'use strict';
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst inputBytes = [229];
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_cipromise_test(async () => {
101cb0ef41Sopenharmony_ci  const input = readableStreamFromArray([new Uint8Array(inputBytes)]);
111cb0ef41Sopenharmony_ci  const output = input.pipeThrough(new TextDecoderStream());
121cb0ef41Sopenharmony_ci  const array = await readableStreamToArray(output);
131cb0ef41Sopenharmony_ci  assert_array_equals(array, ['\uFFFD'], 'array should have one element');
141cb0ef41Sopenharmony_ci}, 'incomplete input with error mode "replacement" should end with a ' +
151cb0ef41Sopenharmony_ci   'replacement character');
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_cipromise_test(async t => {
181cb0ef41Sopenharmony_ci  const input = readableStreamFromArray([new Uint8Array(inputBytes)]);
191cb0ef41Sopenharmony_ci  const output = input.pipeThrough(new TextDecoderStream(
201cb0ef41Sopenharmony_ci      'utf-8', {fatal: true}));
211cb0ef41Sopenharmony_ci  const reader = output.getReader();
221cb0ef41Sopenharmony_ci  await promise_rejects_js(t, TypeError, reader.read(),
231cb0ef41Sopenharmony_ci                        'read should reject');
241cb0ef41Sopenharmony_ci}, 'incomplete input with error mode "fatal" should error the stream');
25