tweag / monad-bayes

A library for probabilistic programming in Haskell.
MIT License
410 stars 62 forks source link

Refactoring proposal: Reorder tests #240

Open turion opened 1 year ago

turion commented 1 year ago

Right now the structure of tests is:

For example we have in Spec.hs:

  describe "Population" do
    context "controlling population" do
      it "preserves the population when not explicitly altered" do
        popSize <- TestPopulation.popSize
        popSize `shouldBe` 5

And in TestPopulation.hs:

popSize :: IO Int
popSize =
  sampleIOfixed (weightedSampleSize $ spawn 5 >> sprinkler)

To understand whether the test is correct, and also to write a new test, I need to deal with both files and keep them in sync. Also, Spec.hs will grow longer and longer to the point where one has to jump around a lot in the file to search for (halves of) tests.

Proposal

How about refactoring like this: