Repository navigation
examples: capability-dependent demo library + app with both negative tests (#5957) - #6237
Merged
Merged
Conversation
…tests (#5957) Greeter (pkgs/id/examples/roc-cap-demo/lib) is a Roc package whose library depends on the platform records.read capability via RocCap; main.roc is the demo app importing it. Negative tests: the same app+library against the reduced platform-no-caps.roc must fail over the missing pf.RocCap (A), and a wrong-signature schedule_at_request call must fail with a type mismatch (B). Both are wired into scripts/roc-test.sh so they run in the roc-test flake check.
developing-today
Bot
requested review from
a team and
dezren39
as code owners
November 5, 2026 13:52
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #5957 (queue task 10533): a demo library + app demonstrating the Roc library import model for worlds, where the library depends on a platform capability.
What
pkgs/id/examples/roc-cap-demo/lib/— the demo library, a Roc package.Greeter.rocgreets world participants by name; the names live in the world records, so the library issues arecords.readcapability request through the platform'sRocCapprotocol helpers. It is therefore not pure: it only works on a platform providing that capability. All protocol handling (issuing, announcing inwants, routing results by id, retiring requests, session snapshot/restore) lives in the library.pkgs/id/examples/roc-cap-demo/main.roc— the demo app importing the library via the package; it only decodes host events and renders greetings.pkgs/id/examples/roc-world/platform-no-caps.roc— a reduced platform fixture:platform.rocwithRocCapremoved fromexposes/imports.Both negative tests (acceptance criteria)
Wired into
scripts/roc-test.sh(theroc-testjust recipe / flake check) viaroc-cap-demo-test.sh, so they run in the normal test flow:main-missing-cap.roc— the same app + library bound to the reduced platform — must fail to compile, and the failure must name the missingpf.RocCapmodule (asserted, not just any failure).main-wrong-usage.roccallsRocCap.schedule_at_requestwith a wrong signature — must fail with a type mismatch at that call (asserted).The positive path (library
expecttests + app typecheck) runs first in the same script.Verification
bash scripts/roc-test.shpasses — 108 library expects (incl. 5 new Greeter expects; mutation-checked: breaking one expect fails the run), app checks clean, both negative tests fail for the pinned reasons.Note:
lib-no-caps/Greeter.rocis a byte-identical copy oflib/Greeter.roc(Roc package modules cannot be symlinked from outside the package root); the test script fails if the copies drift. The harness is namedroc-cap-demo-test.shbecausepkgs/id/.gitignoreignorestest.*.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.