You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It was unclear how to run the fuzzer - I eventually figured out it should be compiled with tsc and run with node:
import{chunkStringIntoFours}from"../src/chunkStringIntoFours";functionchunkStringIntoFoursForLoop(input: string): string{if(typeofinput!=="string"){throwError("chunkStringIntoFours can only chunk strings");}if(/[\uD800-\uDBFF]/.test(input)){throwError("chunkStringIntoFours does not support non BMP strings");}if(/[\r\n]/.test(input)){throwError("chunkStringIntoFours does not support whitespace");}constarray=[];// make input.length / 4 strings that contain 4 charactersfor(leti=0;i<input.length;i++){if(i%4===0){array[Math.floor(i/4)]=input[i];}else{array[Math.floor(i/4)]+=input[i];}}returnarray.join(" ");}import{fuzz}from"fuzzing";consterrors=fuzz((input)=>{try{if(chunkStringIntoFours(input)!==chunkStringIntoFoursForLoop(input)){throwError("chunkStringIntoFours did not output the same as chunkStringIntoFoursForLoop");}}catch(e: unknown){if(einstanceofError&&["chunkStringIntoFours can only chunk strings"].includes(e.message)){// no errorreturntrue;}throwe;}}).string().errors();console.log(errors);
Example script that I made that imports the function to be tested and then I have an npm script:
It was unclear how to run the fuzzer - I eventually figured out it should be compiled with
tsc
and run withnode
:Example script that I made that imports the function to be tested and then I have an npm script:
The text was updated successfully, but these errors were encountered: