This started out as a crazy idea I had during a Stainless hackathon! Let's see what y'all do with it 👀
This started out as a crazy idea I had during a Stainless hackathon! Let's see what y'all do with it 👀
have been checking out lfi recently - fairly small library of very useful async utils
in repos that pull a lot of separate async util packages in, this could be a good unified replacement
Lovely to hear you're finding it useful :)
And thanks for sponsoring! Definitely let me know if you run into any issues
That's why the top AI model providers, fast-growing fintechs, and developer-first platforms all depend on Stainless.
I'm beyond proud to be part of this team!
APIs are everywhere, and using one should be easy, but often times it's not!
Stainless's SDKs make using an API a delight. Focus on your core business without worrying about the nitty gritty details of network calls.
www.stainlessapi.com/blog/stainle...
My solution for today! Pretty happy with how this one turned out
gist.github.com/TomerAberbac...
Well, I'll try to test more targeted slices next time to make sure I'm most likely not duplicating the code under test
Ya know, I think it's a bit more difficult for me to write a good property-based test when I don't see the implementation...
In this case I probably basically reimplemented the function under test when normally I would be more cognizant of that and would test a slice of the input space like you did
const letterArb = fc.record({ id: fc.string() }); test("helping Santa", () => { fc.assert( fc.property(fc.array(letterArb), (letters) => { const deduplicatedLetters = dropLettersFromDuplicatedSenders(letters); const lettersById = Map.groupBy(letters, ({ id }) => id); const expectedLetters = Array.from( lettersById.values(), (letters) => letters[0] ); // Manually check length and individual items for reference equality. expect(deduplicatedLetters.length).toBe(expectedLetters.length); for (let i = 0; i < deduplicatedLetters.length; i++) { expect(deduplicatedLetters[i]).toBe(expectedLetters[i]); } }) ); });
My solution for today! Got to use some brand new ECMAScript features for it
const nameArb = fc.stringMatching(/^[a-z]+$/); const ageArb = fc.integer({ min: 7, max: 77 }); test("helping Santa", () => { fc.assert( fc.property( fc .tuple(ageArb, fc.array(nameArb)) .map(([age, names]) => [age, names.map((name) => ({ name, age }))]), ([age, letters]) => { const sortedLetters = sortLetters(letters); expect(sortedLetters.length).toBe(letters.length); for (const letter of letters) { expect(letter.age).toBe(age); } for (let i = 1; i < sortedLetters.length; i++) { const previousLetter = sortedLetters[i - 1]; const currentLetter = sortedLetters[i]; // Failed here! expect(previousLetter.name <= currentLetter.name).toBe(true); } } ) ); });
Just went ahead and tried it! This worked right away
So close to being a teapot! (iykyk)
GITHUB RECEIPT SUNDAY, NOVEMBER 17, 2024 ORDER #4457 CUSTOMER: Tomer Aberbach @TomerAberbach REPOSITORIES 77 STARS EARNED 1584 REPO FORKS 118 FOLLOWERS 307 FOLLOWING 345 TOP LANGUAGES: JavaScript, TypeScript, Shell MOST ACTIVE DAY: Monday COMMITS (30d): 137 CONTRIBUTION SCORE: 4089 Served by: Linus Torvalds 8:29:25 PM COUPON CODE: 2RQ50T Save for your next commit! CARD #: **** **** **** 2024 AUTH CODE: 410658 CARDHOLDER: TOMERABERBACH THANK YOU FOR CODING! github.com/TomerAberbach
Nice :)
gitreceipt.vercel.app
I encountered a strange bug while working on Docs at Google. Read about it on my blog!
tomeraberba.ch/when-two-bug...
So... Is this the place where the blue bird went?