1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +00:00

LibWeb/Tests: Add basic tests for {ByteLength,Counting}QueuingStrategy

This commit is contained in:
Shannon Booth 2023-06-18 20:49:18 +12:00 committed by Andreas Kling
parent f86c3ab148
commit 464e428e94
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,33 @@
<script src="../include.js"></script>
<script>
test(() => {
function checkHighWaterMarkForClass(cls, object) {
try {
const strat = new cls(object);
println(`'${JSON.stringify(object)}' => ${strat.highWaterMark}`);
} catch (e) {
println(`'${JSON.stringify(object)}' => Exception raised of ${e.constructor.name}`);
}
}
for (cls of [
CountQueuingStrategy,
ByteLengthQueuingStrategy,
]) {
println("======================================")
println(cls.name)
println("======================================")
for (strat of [
{ highWaterMark: 2 },
{ highWaterMark: -1 },
{ badKey: -1 },
{},
"string instead",
{ highWaterMark: "wrongType" },
{ highWaterMark: {} },
]) {
checkHighWaterMarkForClass(cls, strat);
}
}
});
</script>