frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

What if writing tests was a joyful experience? (2023)

https://blog.janestreet.com/the-joy-of-expect-tests/
29•ryanhn•4h ago

Comments

o_nate•3h ago
This is a cool idea. I wish something like this existed for C#.
PretzelPirate•1h ago
An Agentic coding tool like Github Copilot will do this for you.
deathanatos•1h ago
> You start writing assert fibonacci(15) == ... and already you’re forced to think. What does fibonacci(15) equal? If you already know, terrific—but what are you meant to do if you don’t?

Um …duh? Get out a calculator. Consult a reference, etc. Otherwise compute the result, and ensure you've done that correctly, ideally as independent of the code under test as possible. A lot of even mathematical stuff has "test vectors"; e.g., the SHA algorithms.

> Here’s how you’d do it with an expect test:

  printf "%d" (fibonacci 15);
  [%expect {||}]
> The %expect block starts out blank precisely because you don’t know what to expect. You let the computer figure it out for you. In our setup, you don’t just get a build failure telling you that you want 610 instead of a blank string. You get a diff showing you the exact change you’d need to make to your file to make this test pass; and with a keybinding you can “accept” that diff. The Emacs buffer you’re in will literally be overwritten in place with the new contents:

…you're kidding me. This is "fix the current state of the function — whether correct or not — as the expected output."

Yeah… no kidding that's easier.

We gloss over errors — "some things just looked incorrect" — well, but how do you know that any differently than fib(10)?

nippoo•32m ago
A lot of tests are designed as regression prevention. You know the system is working as designed, but what if somebody comes along and changes the Fibonacci function to compute much more efficiently (and, in the process, makes some arithmetic errors?).
Storment33•28m ago
It is called snapshot testing, very valid technique. Maybe not best suited to a mathematical function like they have here, but I have found it useful for stuff like compilers asserting on the AST, where it would be a pain to write out and assert on the output and may also change shape.
breatheoften•47m ago
I really like this style of testing -- code that can be tested this way is also the most fun kind of code to work with and the most likely to behave predictably.

I love determinism and plain old data.

Joel_Mckay•1m ago
Could look at high-level constraint modelling languages:

https://www.minizinc.org/

It often bypasses the need to get bogged down in probabilistic markdown syntax =3

https://www.youtube.com/watch?v=X6WHBO_Qc-Q

mayoff•46m ago
If you’re a Swift programmer, the swift-snapshot-testing package is a great implementation of these ideas.

https://github.com/pointfreeco/swift-snapshot-testing

tomhow•27m ago
Discussed at the time:

What if writing tests was a joyful experience? - https://news.ycombinator.com/item?id=34350749 - Jan 2023 (122 comments)

TacticalCoder•22m ago
Amazing to see Jane Street uses Emacs. And property-based testing too.

> you don’t just get a build failure telling you that you want 610 instead of a blank string

So I had to scratch my head a bit because I was thinking: "Wait, the whole point is that you don't know whether what you're testing is correct or not, so how can you rely on that as input to your tests!?".

But even though I didn't understand everything they do yet I do see at least a big case where it makes lots of sense. And it happens to be a case where a lot of people see the benefits of test: before refactoring.

> What does fibonacci(15) equal? If you already know, terrific—but what are you meant to do if you don’t?

Yeah a common one is reuse a function in the same language which you believe is correct (you probably haven't proven it to be correct). Another typical one is you reuse a similar function from another language (once again, it's probably not been proven it is correct). But if two implementation differ, you know you have an issue.

> let d = create_marketdata_processor () in > ( Do some preprocessing to define the symbol with id=1 as "APPL" )

Typo. It's AAPL, not APPL. It's correctly used as AAPL later on.

FWIW writing tests better become a joyful experience for we're going to need a lot* of these with all our AI generated code.

mlmonkey•20m ago
Recently, I have given up on writing unit tests, instead prompting an LLM to write them for me. I just sit back and keep prompting it until it gets it right. Sometimes it goes a little haywire in our Monorepo, but I don't have to accept its changes.

It feels ... strangely empowering.

Claude Opus 4.6

https://www.anthropic.com/news/claude-opus-4-6
1585•HellsMaddy•8h ago•671 comments

It's 2026, Just Use Postgres

https://www.tigerdata.com/blog/its-2026-just-use-postgres
391•turtles3•4h ago•209 comments

GPT-5.3-Codex

https://openai.com/index/introducing-gpt-5-3-codex/
1049•meetpateltech•8h ago•401 comments

My AI Adoption Journey

https://mitchellh.com/writing/my-ai-adoption-journey
336•anurag•7h ago•87 comments

We tasked Opus 4.6 using agent teams to build a C Compiler

https://www.anthropic.com/engineering/building-c-compiler
382•modeless•7h ago•358 comments

Recreating Epstein PDFs from raw encoded attachments

https://neosmart.net/blog/recreating-epstein-pdfs-from-raw-encoded-attachments/
213•ComputerGuru•1d ago•46 comments

Animated Knots

https://www.animatedknots.com/
56•ostacke•3d ago•8 comments

Review of 1984 by Isaac Asimov (1980)

https://www.newworker.org/ncptrory/1984.htm
86•doruk101•4h ago•36 comments

MenuetOS – a GUI OS that boots from a single floppy disk

https://www.menuetos.net/
105•pjerem•2d ago•16 comments

LinkedIn checks for 2953 browser extensions

https://github.com/mdp/linkedin-extension-fingerprinting
293•mdp•6h ago•142 comments

The RCE that AMD won't fix

https://mrbruh.com/amd/
44•MrBruh•2h ago•14 comments

Launching My Side Project as a Solo Dev: The Walkthrough

https://alt-romes.github.io/posts/2026-01-30-from-side-project-to-kickstarter-a-walkthrough.html
22•romes•4d ago•1 comments

Claude Opus 4.6 extra usage promo

https://support.claude.com/en/articles/13613973-claude-opus-4-6-extra-usage-promo
107•rob•6h ago•29 comments

Orchestrate teams of Claude Code sessions

https://code.claude.com/docs/en/agent-teams
310•davidbarker•8h ago•171 comments

Flock CEO calls Deflock a “terrorist organization” (2025) [video]

https://www.youtube.com/watch?v=l-kZGrDz7PU
476•cdrnsf•7h ago•321 comments

What's wrong with bunny hands on dinosaurs? (2018)

https://paleoaerie.org/2018/06/13/whats-wrong-with-bunny-hands-on-dinosaurs/
26•exvi•5d ago•12 comments

Show HN: Local task classifier and dispatcher on RTX 3080

https://github.com/resilientworkflowsentinel/resilient-workflow-sentinel
5•Shubham_Amb•2h ago•0 comments

There Will Come Soft Rains (1950) [pdf]

https://www.btboces.org/Downloads/7_There%20Will%20Come%20Soft%20Rains%20by%20Ray%20Bradbury.pdf
143•wallflower•4d ago•36 comments

C isn't a programming language anymore (2022)

https://faultlore.com/blah/c-isnt-a-language/
20•stickynotememo•2h ago•21 comments

What if writing tests was a joyful experience? (2023)

https://blog.janestreet.com/the-joy-of-expect-tests/
29•ryanhn•4h ago•11 comments

OpenClaw: When AI Agents Get Full System Access. Security nightmare?

https://innfactory.ai:443/en/blog/openclaw-ai-agent-security/
46•i-blis•4d ago•26 comments

Housman's Introductory Lecture (1892)

https://worrydream.com/refs/Housman_1892_-_Introductory_Lecture.html
5•coloneltcb•3d ago•0 comments

150 MB Minimal FreeBSD Installation

https://vermaden.wordpress.com/2026/02/01/150-mb-minimal-freebsd-installation/
129•vermaden•5d ago•23 comments

Maihem (YC W24): hiring senior robotics perception engineer (London, on-site)

https://jobs.ashbyhq.com/maihem/8da3fa8b-5544-45de-a99e-888021519758
1•mxrns•9h ago

Ardour 9.0

https://ardour.org/whatsnew.html
241•PaulDavisThe1st•7h ago•51 comments

PsiACE/Skills – A small, shared skill library

https://github.com/PsiACE/skills
46•recrush•8h ago•4 comments

Fela Kuti First African to Get Grammys Lifetime Achievement Award

https://www.aljazeera.com/news/2026/2/1/fela-kuti-becomes-first-african-to-get-grammys-lifetime-a...
156•defrost•4d ago•35 comments

Don't rent the cloud, own instead

https://blog.comma.ai/datacenter/
1082•Torq_boi•20h ago•450 comments

Bitcoin gets a zero price target in wake of Burry warning

https://seekingalpha.com/news/4547997-bitcoin-s-price-target-at-zero
17•hn_acker•1h ago•5 comments

Nanobot: Ultra-Lightweight Alternative to OpenClaw

https://github.com/HKUDS/nanobot
217•ms7892•16h ago•111 comments