From 779d9dfb69ddc2249b1fc3d5454bc777223e960a Mon Sep 17 00:00:00 2001 From: Dan Steren Date: Wed, 1 Nov 2023 16:19:08 -0600 Subject: [PATCH] Stylistic fixes --- property_tests/tests/blob/test/test.ts | 11 ++++++----- property_tests/tests/bool/test/test.ts | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/property_tests/tests/blob/test/test.ts b/property_tests/tests/blob/test/test.ts index 56e4108c3b..b29cc37ef8 100644 --- a/property_tests/tests/blob/test/test.ts +++ b/property_tests/tests/blob/test/test.ts @@ -16,16 +16,12 @@ const BlobTestArb = fc ) .map(([functionName, paramBlobs, defaultReturnBlob]): TestSample => { const imports = defaultReturnBlob.src.imports; - const paramNames = paramBlobs.map((_, index) => `param${index}`); const paramCandidTypes = paramBlobs .map((blob) => blob.src.candidType) .join(', '); - const returnCandidType = defaultReturnBlob.src.candidType; - const body = generateBody(paramNames, paramBlobs, defaultReturnBlob); - const test = generateTest(functionName, paramBlobs, defaultReturnBlob); return { @@ -58,13 +54,18 @@ function generateBody( // TODO maybe a global variable that we can write into and call would work const paramsCorrectlyOrdered = paramNames .map((paramName, index) => { - return `if (${paramName}.length !== ${paramBlobs[index].value.length}) throw new Error('${paramName} is incorrectly ordered')`; + const paramIsCorrectLength = `${paramName}.length === ${paramBlobs[index].value.length}`; + + const throwError = `throw new Error('${paramName} is incorrectly ordered')`; + + return `if (!(${paramIsCorrectLength})) ${throwError};`; }) .join('\n'); const returnStatement = `Uint8Array.from([${[...returnBlob.value]} ${ returnBlob.value.length > 0 ? ',' : '' } ${paramNames.map((paramName) => `...${paramName}`).join(', ')}])`; + return ` ${paramsAreUint8Arrays} diff --git a/property_tests/tests/bool/test/test.ts b/property_tests/tests/bool/test/test.ts index 7c4034a094..32d0e065f3 100644 --- a/property_tests/tests/bool/test/test.ts +++ b/property_tests/tests/bool/test/test.ts @@ -31,9 +31,9 @@ const BoolTestArb = fc return { imports, functionName, + paramNames, paramCandidTypes, returnCandidType, - paramNames, body, test };