Skip to content

[claude-experiments] Add verification tests for nullable type operations#60

Open
jesyspa wants to merge 5 commits intomainfrom
botspace/nullability-verification-tests
Open

[claude-experiments] Add verification tests for nullable type operations#60
jesyspa wants to merge 5 commits intomainfrom
botspace/nullability-verification-tests

Conversation

@jesyspa
Copy link
Copy Markdown
Collaborator

@jesyspa jesyspa commented Mar 10, 2026

Summary

Adds verification tests for nullability operations to the existing verification/nullability.kt file. Each test exercises a distinct code path:

  • nullablePassthrough: nullable parameter identity (return x where x: Int?)
  • elvisWithNonNull: elvis operator passthrough when value is non-null
  • smartcastInBranch: smart cast after null check in if-else

The existing return_null test (null literal return) is preserved.

Context

Part of the design accuracy audit for nullability encoding. These tests verify that the RuntimeTypeDomain-based nullable encoding produces correct results, not just valid Viper.

Test plan

  • Golden files generated with z3 verification
  • All tests pass
  • Checked against existing tests — no duplication
  • Rebased on latest main, conflicts resolved

🤖 Generated with Claude Code

jesyspa and others added 5 commits March 11, 2026 09:39
The API declaration file was not regenerated after the addition of
InvariantBuilder.triggers() and the @Manual annotation, causing
apiCheck to fail on a clean build.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
7 new verification tests covering:
- Elvis operator with null input (proves default value is returned)
- Elvis operator with non-null input (proves passthrough)
- Nullable passthrough (proves identity preservation)
- Null literal return (proves result is null)
- Null comparison on null value (proves true)
- Non-null comparison on null value (proves false)
- Smart cast in if-else branch (proves type narrowing)

All tests pass Viper verification with z3.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move tests from nullability_operations.kt into the existing
verification/nullability.kt file. Use file-level ALWAYS_VALIDATE
instead of per-function @AlwaysVerify to match the existing convention.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep only tests that exercise genuinely different mechanisms:
- return_null: null literal
- nullablePassthrough: nullable parameter identity
- elvisWithNonNull: elvis operator passthrough
- smartcastInBranch: smart cast after null check

Remove redundant tests (returnNullLiteral duplicates return_null,
null comparisons are trivial, elvisDefaultOnNull is simpler case
of elvis already covered).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jesyspa jesyspa force-pushed the botspace/nullability-verification-tests branch from bbdc14a to 5adacfb Compare March 11, 2026 08:43
@jesyspa jesyspa changed the title Add verification tests for nullable type operations [claude-experiments] Add verification tests for nullable type operations Apr 4, 2026
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