Files
zeekay a61bcad919 fix(haskell): green build+test on GHC 9.6 + provision zap front-end in CI
Library + zapc-haskell already compiled; this finishes the test suite and CI:
- SchemaGeneration.hs: import Control.Monad (replicateM) — mtl 2.3 stopped
  re-exporting Control.Monad from Control.Monad.State.Strict.
- Module/Zap/Rpc.hs (expectException): GHC 9.6's stricter ambiguity check +
  waitPipeline's ReprFor a ~ 'Ptr pr rewrite broke the fundep-resolved Parse
  constraint. Pin the parsed type to  and annotate the bound result
  (forall + ScopedTypeVariables) so GHC discharges Parse a (Parsed a) directly.
- Regression.hs: regenerate the issue-#56 abort-message wire bytes — the rebrand
  find-replaced capnproto->zap INSIDE the binary literal, shortening the embedded
  text without updating the list-pointer length -> TraversalLimitError. Rebuilt
  via parsedToLBS of the expected Message.
- zap-tests.cabal: drop the phantom 'benchmark bench' stanza (bench/Main.hs was
  never in the repo) and the broken examples/ test source dirs.
- cabal.project: allow-newer lifetimes:transformers (stale upstream bound; GHC
  9.4+ ships transformers 0.6 and lifetimes compiles against it).
- ci.yml: build+install the zap schema front-end from cpp-core (the integration
  tests shell out to it), mirroring the Rust install-zap step.

Local: cabal build all + cabal test all => 165 examples, 0 failures (GHC 9.6.7).
2026-06-20 12:33:31 -07:00

42 lines
2.0 KiB
Haskell

{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
module Regression (regressionTests) where
import Zap (bsToParsed, def, evalLimitT)
import Zap.Gen.Aircraft
import Zap.Gen.Zap.Rpc
import Test.Hspec
regressionTests :: Spec
regressionTests = describe "Regression tests" $ do
it "Should decode abort message successfully (issue #56)" $ do
-- Valid serialization of the (zap-branded) abort message below. The earlier
-- literal was corrupted by the capnp->zap rebrand: a find-replace shortened
-- the embedded "...capnproto library" text to "...zap library" without
-- updating the list-pointer length word, so the decoder over-read and threw
-- TraversalLimitError. Regenerated via parsedToLBS of the expected Message.
let bytes =
"\NUL\NUL\NUL\NUL\ETB\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH\NUL\SOH\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH\NUL\SOH\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL\SOH\NUL\NUL\NULJ\EOT\NUL\NULYour vat sent an 'unimplemented' message for an abort message that its remote peer never sent. This is likely a bug in your zap library.\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL"
msg <- evalLimitT maxBound $ bsToParsed bytes
msg
`shouldBe` Message
( Message'abort
def
{ reason =
"Your vat sent an 'unimplemented' message for an abort "
<> "message that its remote peer never sent. This is likely "
<> "a bug in your zap library.",
type_ = Exception'Type'failed
}
)
it "Should decode negative default values correctly (issue #55)" $ do
-- Note that this was never actually broken, but we were getting
-- a warning about a literal overflowing the bounds of its type.
-- It worked anyway, since it became the right value after casting,
-- but the warning has been fixed and this test makes sure it still
-- actually works.
let Defaults {int} = def
int `shouldBe` (-123)