Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/briefs/r1-testgen-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ Lane-owner dispatch status (update as sub-deliverables close):
- [ ] `testgen_structural_coverage` gate compiles + evaluates
- [ ] `MockBackedInvariant` wiring
- [ ] `testgen_mock_backed_integration_safe` gate compiles + evaluates
- [ ] `testgen_manual_claim_is_first_class` gate compiles + evaluates
- [x] `testgen_manual_claim_is_first_class` gate compiles + evaluates
(`src/v3/compiler/tests/fixtures/r1_gates.dag` + `r1_manual_claim_gate_test.rs`)

**T-LensAPI:**
- [ ] `user_authored_lens_compiles` gate (Day-1) passes
Expand Down
26 changes: 25 additions & 1 deletion src/v3/compiler/tests/fixtures/r1_gates.dag
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
// `Compiles` receipt). Payload is a standalone `module lenses.named_function_count`
// unit (imports std only), not a consumer that imports this module from bootstrap.
//
// **T-TestGen** (`testgen_manual_claim_is_first_class`, ROADMAP.md:51, [ext]): hand-authored
// `manual_negative_claim_gate` + `manual_claim_suite` live in this same module so one
// fixture file stays the R1 gate surface without growing `src/v3/std/*.dag` (bootstrap
// enumerates that tree — see PR #679 / review round 1).
//
// Lives under `src/v3/compiler/tests/fixtures/` so it is **not** auto-staged
// into `Dag::new()` bootstrap (`src/v3/std/*.dag` is build-script enumerated).

module std.r1_gates

import std.verification { TestClaim }
import std.verification { TestClaim, TestSuite }

data user_authored_lens_compiles_gate: TestClaim = {
name: "user_authored_lens_compiles",
Expand All @@ -21,3 +26,22 @@ data user_authored_lens_compiles_gate: TestClaim = {
predicate: Compiles,
requires: []
}

// Fixture: return type says `String` but body is `Int` (`x`). The substrate surfaces
// this as `ResolveError` ("parameter … does not satisfy its declared signature"), not
// `TypeMismatch` — the gate matches the live diagnostic kind.
data manual_negative_claim_gate: TestClaim = {
name: "testgen_manual_claim_is_first_class",
source: "fn broken(x: Int) -> String = x",
file_name: "manual_claim_fixture.v3",
predicate: FailsWithDiagnostic({
kind: ResolveError,
detail_contains: AnyDetail
}),
requires: []
}

data manual_claim_suite: TestSuite = {
name: "manual_claim_suite",
claims: [manual_negative_claim_gate]
}
2 changes: 2 additions & 0 deletions src/v3/compiler/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ mod pb1_bootstrap_full_snapshot_test;
mod pb1_bootstrap_std_snapshot_test;
#[path = "integration/pipe_desugar.rs"]
mod pipe_desugar;
#[path = "integration/r1_manual_claim_gate_test.rs"]
mod r1_manual_claim_gate_test;
#[path = "integration/sg0_census_test.rs"]
mod sg0_census_test;
#[path = "integration/sg1_tokenize_authority_test.rs"]
Expand Down
41 changes: 41 additions & 0 deletions src/v3/compiler/tests/integration/r1_manual_claim_gate_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//! **Layer:** integration
//!
//! R1 T-TestGen gate `testgen_manual_claim_is_first_class` (ROADMAP.md:51, `[ext]`):
//! hand-authored `TestClaim` values in `tests/fixtures/r1_gates.dag` (shared with the
//! Day-1 lens gate) compile via `compile_to_dag` and run through the same
//! `TestRunner::run_suite` dispatch as generated claims (`test_runner.rs`).
//!
//! Gate fixtures live under `src/v3/compiler/tests/fixtures/` so they are **not**
//! enumerated into `Dag::new()` bootstrap (`src/v3/std/*.dag` is build-script staged).

use std::path::PathBuf;

use v3_compiler::compile_to_dag;
use v3_compiler::test_runner::{ClaimResult, TestRunner};
use v3_compiler::CompileError;

fn compile_clean(source: &str, file: &str) -> v3_compiler::dag::Dag {
match compile_to_dag(source, file) {
Ok(dag) => dag,
Err(CompileError::Semantic(dag)) => panic!(
"{file} should compile cleanly, got {:?}",
dag.diagnostics().iter().collect::<Vec<_>>()
),
Err(err) => panic!("{file} should compile cleanly, got {err:?}"),
}
}

#[test]
fn testgen_manual_claim_is_first_class_gate_passes() {
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let repo_root = manifest_dir.ancestors().nth(3).expect("repo root");
let gate = repo_root.join("src/v3/compiler/tests/fixtures/r1_gates.dag");
let source =
std::fs::read_to_string(&gate).unwrap_or_else(|err| panic!("read {gate:?}: {err}"));
let dag = compile_clean(&source, "src/v3/compiler/tests/fixtures/r1_gates.dag");
let results = TestRunner::new(&dag).run_suite("manual_claim_suite");

assert_eq!(results.len(), 1, "expected one claim in manual_claim_suite");
assert_eq!(results[0].claim_name, "testgen_manual_claim_is_first_class");
assert_eq!(results[0].result, ClaimResult::Pass);
}
1 change: 1 addition & 0 deletions src/v3/compiler/tests/integration/sg0_census_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ const EXPECTED_HAND_AUTHORED_TEST: &[&str] = &[
"src/v3/compiler/tests/integration/pb1_bootstrap_full_snapshot_test.rs",
"src/v3/compiler/tests/integration/pb1_bootstrap_std_snapshot_test.rs",
"src/v3/compiler/tests/integration/pipe_desugar.rs",
"src/v3/compiler/tests/integration/r1_manual_claim_gate_test.rs",
"src/v3/compiler/tests/integration/sg0_census_test.rs",
"src/v3/compiler/tests/integration/sg1_tokenize_authority_test.rs",
"src/v3/compiler/tests/integration/sg2_parse_authority_test.rs",
Expand Down
12 changes: 4 additions & 8 deletions src/v3/compiler/tests/integration/test_runner_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,13 @@ data suite: TestSuite = {
}

#[test]
#[ignore = "Brief 1 dependency: std/r1_gates.dag/user_authored_lens_compiles_gate is not present in this worktree yet"]
#[ignore = "Brief 1 dependency: user_authored_lens_compiles gate wiring still pending"]
fn test_runner_runs_user_authored_lens_compiles_gate() {
let repo_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(3)
.expect("repo root")
.to_path_buf();
let gate = repo_root.join("src/v3/std/r1_gates.dag");
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let gate = manifest_dir.join("tests/fixtures/r1_gates.dag");
let source =
std::fs::read_to_string(&gate).unwrap_or_else(|err| panic!("read {gate:?}: {err}"));
let dag = compile_clean(&source, "src/v3/std/r1_gates.dag");
let dag = compile_clean(&source, "src/v3/compiler/tests/fixtures/r1_gates.dag");
let results = TestRunner::new(&dag).run_suite("user_authored_lens_compiles_gate");

assert_all_pass(&results);
Expand Down
Loading