Skip to content

Add runtime test suite for ema lib #178

Description

@srid

The ema package currently has no runtime test harness. ema-generics has a test-type-errors suite, but that only exercises compile-time behaviour for the generics derivations — there's no place to land hspec/tasty-style unit tests for ema itself.

This blocked adding a test for Ema.Dynamic.currentValue in #177, which would have needed:

  • a new test-suite stanza in ema.cabal
  • an hspec or tasty dep (neither currently pulled in)
  • a test/Spec.hs + per-module spec layout

Doing that on its own PR would be ~50 lines of pure plumbing before any test logic lands. Better done once, as a standalone setup PR, after which future feature PRs can drop in new specs cheaply.

What a minimal setup looks like

test-suite test
  import:           extensions
  type:             exitcode-stdio-1.0
  hs-source-dirs:   test
  main-is:          Spec.hs
  build-depends:    base, ema, hspec
  default-language: Haskell2010

Then test/Ema/DynamicSpec.hs can exercise currentValue:

spec = describe "currentValue" $ do
  it "returns initial value before consumption" $ do
    (readNow, _) <- currentValue (Dynamic (42 :: Int, \_ -> pass))
    readNow `shouldReturn` 42
  it "tracks updates once the wrapped Dynamic is consumed" $ do
    (readNow, Dynamic (_, xf)) <- currentValue
      (Dynamic (0 :: Int, \send -> mapM_ send [1, 2, 3]))
    xf pass  -- drive the updater once
    readNow `shouldReturn` 3

Tracks the dependency chain: #177 wants these, downstream srid/emanote#649 relies on the behaviour in production.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions