Skip to content

test the euler characteristic in the test suite, and add a mechanism …#499

Merged
julialongtin merged 2 commits intomasterfrom
test_euler_characteristic
Mar 19, 2026
Merged

test the euler characteristic in the test suite, and add a mechanism …#499
julialongtin merged 2 commits intomasterfrom
test_euler_characteristic

Conversation

@julialongtin
Copy link
Member

…for a test to specify a resolution.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for inline primitive-module tests to specify a rendering/discretization resolution, and wires those inline tests into the Hspec suite by checking mesh Euler characteristics.

Changes:

  • Extend ArgParser’s APTest node to carry an optional resolution and update consumers (e.g., docgen).
  • Add atResolution and collectTests helpers for inline tests in Util.ArgParser.
  • Run collected inline primitive tests in tests/ImplicitSpec.hs by executing SCAD and validating invariants (Euler characteristic) on the discretized mesh.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/ImplicitSpec.hs Collects inline tests from primitiveModules, runs them via runOpenscad, and checks Euler characteristic invariants.
programs/docgen.hs Updates APTest pattern match to reflect the new constructor shape.
implicit.cabal Exposes Graphics.Implicit.ExtOpenScad.Util.ArgParser so the test suite can import collectTests.
Graphics/Implicit/ExtOpenScad/Util/ArgParser.hs Adds per-test resolution support (atResolution) and extraction of inline tests (collectTests); updates APTest constructor usage.
Graphics/Implicit/ExtOpenScad/Primitives.hs Moves/adds inline tests near the start of primitive argparsers; temporarily comments out broken/unsupported ones.
Graphics/Implicit/ExtOpenScad/Definitions.hs Extends APTest to include Maybe ℝ resolution and updates the Monad instance accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +85 to +86
| isJust maybeRes = error "tried to set a resolution of a test twice."
| otherwise = APTest str (Just res) tests child
collectTests :: ArgParser a -> [(Text, Maybe ℝ, [TestInvariant])]
collectTests (APTest str maybeRes tests child) = (str, maybeRes, tests) : collectTests child
collectTests (APExample _ child) = collectTests child
collectTests (APBranch branches) = concatMap collectTests branches
Comment on lines +417 to +419
f = length triangles
e = length $ nub $ concatMap edges triangles
v = length $ nub $ concatMap vertices triangles
@julialongtin julialongtin merged commit 4cf3943 into master Mar 19, 2026
3 of 6 checks passed
@julialongtin julialongtin deleted the test_euler_characteristic branch March 19, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants