2021-01-11 12:13:41 -05:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2020-09-27 06:22:32 -04:00
|
|
|
import { assertThrows, unitTest } from "./test_util.ts";
|
2020-05-20 20:18:43 -04:00
|
|
|
|
|
|
|
unitTest(function streamReadableHwmError() {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-02 00:24:44 -04:00
|
|
|
const invalidHwm: any[] = [NaN, Number("NaN"), {}, -1, "two"];
|
2020-05-20 20:18:43 -04:00
|
|
|
for (const highWaterMark of invalidHwm) {
|
|
|
|
assertThrows(
|
|
|
|
() => {
|
2020-06-02 00:24:44 -04:00
|
|
|
new ReadableStream<number>(undefined, { highWaterMark });
|
2020-05-20 20:18:43 -04:00
|
|
|
},
|
|
|
|
RangeError,
|
2020-07-14 15:24:17 -04:00
|
|
|
"highWaterMark must be a positive number or Infinity. Received:",
|
2020-05-20 20:18:43 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
assertThrows(() => {
|
|
|
|
new ReadableStream<number>(
|
|
|
|
undefined,
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-07-14 15:24:17 -04:00
|
|
|
{ highWaterMark: Symbol("hwk") as any },
|
2020-05-20 20:18:43 -04:00
|
|
|
);
|
|
|
|
}, TypeError);
|
|
|
|
});
|
|
|
|
|
|
|
|
unitTest(function streamWriteableHwmError() {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-02 00:24:44 -04:00
|
|
|
const invalidHwm: any[] = [NaN, Number("NaN"), {}, -1, "two"];
|
2020-05-20 20:18:43 -04:00
|
|
|
for (const highWaterMark of invalidHwm) {
|
|
|
|
assertThrows(
|
|
|
|
() => {
|
|
|
|
new WritableStream(
|
|
|
|
undefined,
|
2020-07-14 15:24:17 -04:00
|
|
|
new CountQueuingStrategy({ highWaterMark }),
|
2020-05-20 20:18:43 -04:00
|
|
|
);
|
|
|
|
},
|
|
|
|
RangeError,
|
2020-07-14 15:24:17 -04:00
|
|
|
"highWaterMark must be a positive number or Infinity. Received:",
|
2020-05-20 20:18:43 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
assertThrows(() => {
|
|
|
|
new WritableStream(
|
|
|
|
undefined,
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-07-14 15:24:17 -04:00
|
|
|
new CountQueuingStrategy({ highWaterMark: Symbol("hwmk") as any }),
|
2020-05-20 20:18:43 -04:00
|
|
|
);
|
|
|
|
}, TypeError);
|
|
|
|
});
|
|
|
|
|
|
|
|
unitTest(function streamTransformHwmError() {
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-06-02 00:24:44 -04:00
|
|
|
const invalidHwm: any[] = [NaN, Number("NaN"), {}, -1, "two"];
|
2020-05-20 20:18:43 -04:00
|
|
|
for (const highWaterMark of invalidHwm) {
|
|
|
|
assertThrows(
|
|
|
|
() => {
|
2020-06-02 00:24:44 -04:00
|
|
|
new TransformStream(undefined, undefined, { highWaterMark });
|
2020-05-20 20:18:43 -04:00
|
|
|
},
|
|
|
|
RangeError,
|
2020-07-14 15:24:17 -04:00
|
|
|
"highWaterMark must be a positive number or Infinity. Received:",
|
2020-05-20 20:18:43 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
assertThrows(() => {
|
|
|
|
new TransformStream(
|
|
|
|
undefined,
|
|
|
|
undefined,
|
2020-11-03 10:19:29 -05:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2020-07-14 15:24:17 -04:00
|
|
|
{ highWaterMark: Symbol("hwmk") as any },
|
2020-05-20 20:18:43 -04:00
|
|
|
);
|
|
|
|
}, TypeError);
|
|
|
|
});
|