Skip to content

add strictCaseObjects test coverage#62

Draft
aryonoco wants to merge 1 commit into
arnetheduck:masterfrom
aryonoco:upstream-strict-tests
Draft

add strictCaseObjects test coverage#62
aryonoco wants to merge 1 commit into
arnetheduck:masterfrom
aryonoco:upstream-strict-tests

Conversation

@aryonoco
Copy link
Copy Markdown

Draft — depends on #59, #60, #61. This file's assertions exercise the strictCaseObjects-safe code paths introduced by those PRs; its CI will go green once they merge and this branch is rebased onto the merged tip.

Adds `tests/test_strict_caseobjects.nim` — a compile + runtime check that every accessor, combinator, equality, and exception-bridge path through `Result` compiles and behaves identically under `{.experimental: "strictCaseObjects".}` as it does without the pragma.

Thirteen blocks cover the four specialisations (`Result[T, E]`, `Opt[T]`, `Result[void, E]`, `Result[void, void]`) and the exception-bridge surface of `tryValue`: `ref Exception` (including the nil-payload case produced by `Result.default()`), user-defined `toException`, and the opaque-E fallback. `mapCastErr` gets a dedicated block with a same-representation source/target pair (`int32` / `uint32`) since `cast[E1]` requires matching runtime shape.

The nimble `test` task runs the new file under both `c` and `--mm:refc` on Nim >= 2.0. The pragma exists on earlier Nim but the flow-analysis diagnostics this test exercises are only stabilised on modern Nim, so older runs are unaffected.

Adds tests/test_strict_caseobjects.nim — a compile + runtime check
that every accessor, combinator, equality, and exception-bridge path
through Result compiles and behaves identically under
`{.experimental: "strictCaseObjects".}` as it does without the pragma.

Thirteen sections cover the four specialisations
(Result[T, E] / Opt[T] / Result[void, E] / Result[void, void]) and
the exception-bridge surface of `tryValue`: ref Exception (including
the nil-payload case produced by `Result.default()`), user-defined
`toException`, and the opaque-E fallback. `mapCastErr` gets a
dedicated block with a same-representation source/target pair since
`cast[E1]` requires it.

The nimble `test` task runs the new file under both `c` and
`--mm:refc` on Nim >= 2.0. The pragma exists on earlier Nim but the
flow-analysis diagnostics this test exercises are only stabilised on
modern Nim, so older runs are not affected.
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.

1 participant