add more test types

This commit is contained in:
Meghan Denny
2024-08-05 22:44:20 -07:00
parent b8e388e573
commit c3b00f589c
2 changed files with 3 additions and 3 deletions

View File

@@ -2292,7 +2292,7 @@ JSC_DEFINE_HOST_FUNCTION(constructJSBuffer, (JSC::JSGlobalObject * lexicalGlobal
return {};
}
return JSBuffer__bufferFromLength(lexicalGlobalObject, length);
} else if (distinguishingArg.isUndefinedOrNull()) {
} else if (distinguishingArg.isUndefinedOrNull() || distinguishingArg.isBoolean()) {
auto arg_string = distinguishingArg.toWTFString(globalObject);
auto message = makeString("The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received "_s, arg_string);
throwTypeError(lexicalGlobalObject, throwScope, message);

View File

@@ -2758,7 +2758,7 @@ it("new Buffer.from()", () => {
describe("fuzzing constructors with new", () => {
const zeroArray = new Uint32Array(10).fill(0);
const sizes = [1e20, 0, 0.1, -1, "a", undefined, null, NaN, 5n, Symbol("xyz")];
const sizes = [1e20, 0, 0.1, -1, "a", undefined, null, NaN, 5n, Symbol("xyz"), true, () => {}, {}];
const allocators = [Buffer, SlowBuffer, Buffer.alloc, Buffer.allocUnsafe, Buffer.allocUnsafeSlow];
for (const allocator of allocators) {
for (const size of sizes) {
@@ -2776,7 +2776,7 @@ describe("fuzzing constructors with new", () => {
describe("fuzzing constructors with call", () => {
const zeroArray = new Uint32Array(10).fill(0);
const sizes = [1e20, 0, 0.1, -1, "a", undefined, null, NaN, 5n, Symbol("xyz")];
const sizes = [1e20, 0, 0.1, -1, "a", undefined, null, NaN, 5n, Symbol("xyz"), true, () => {}, {}];
const allocators = [Buffer, SlowBuffer, Buffer.alloc, Buffer.allocUnsafe, Buffer.allocUnsafeSlow];
for (const allocator of allocators) {
for (const size of sizes) {