7ae92d3e60
closes #60 The fixture-corpus filter (NON_PARSEABLE_FIXTURES + list_ail_fixtures) was copy-pasted across three test crates and drifted out of sync as new reject fixtures landed; the examples_dir / workspace_root path walk was reimplemented ~30 more times across the suite, under two spellings (workspace_root / ws_root). Introduce crates/ailang-test-support — a zero-dependency, dev-only leaf crate — as the single home for these helpers: - NON_PARSEABLE_FIXTURES, list_ail_fixtures - workspace_root, examples_dir - canonical_workspace_root (symlink-resolved variant, for the tsan/ race tests that feed the root into native build steps) All integration-test copies across ailang-core, ailang-surface, ailang-prose, ailang-check, and ail now import from the shared crate; the local definitions and their now-orphaned path imports are removed. Path helpers resolve via the support crate's own CARGO_MANIFEST_DIR, so they return the correct absolute paths from any caller. ail_bin helpers are intentionally left in place: they depend on env!("CARGO_BIN_EXE_ail"), which Cargo only defines when compiling the ail crate's own integration tests, so they cannot move to a shared crate. Behaviour-identical: same paths, same fixture lists; full workspace test suite green. Net -177 LOC.
69 lines
3.0 KiB
Rust
69 lines
3.0 KiB
Rust
//! Repurposed pin tests for the post-`MethodNameCollision`-retirement
|
|
//! workspace-load path. The two on-disk fixtures that fired
|
|
//! `WorkspaceLoadError::MethodNameCollision` before the type-driven
|
|
//! dispatch refactor now load cleanly;
|
|
//! the assertion migrates from "expect collision diagnostic" to "load
|
|
//! successful + `Env.method_to_candidate_classes` carries the
|
|
//! expected multi-entry set" (class-class case) or "load successful +
|
|
//! class-fn coexistence is legal" (class-fn case).
|
|
//!
|
|
//! The relocation from `crates/ailang-core/src/workspace.rs` to this
|
|
//! file is required because the post-retirement assertions read
|
|
//! `Env.method_to_candidate_classes`, which is built by `ailang-check`
|
|
//! (`build_check_env`) and not visible from `ailang-core`.
|
|
|
|
use ailang_check::build_check_env;
|
|
use ailang_surface::load_workspace;
|
|
use ailang_test_support::examples_dir;
|
|
|
|
/// Class-class repurpose: the fixture
|
|
/// `examples/test_22b2_method_name_collision_class_class.ail.json`
|
|
/// declares two classes `A` and `B` in the same module, each declaring
|
|
/// the method `foo`. Pre-canonical-class-form this fired
|
|
/// `WorkspaceLoadError::MethodNameCollision { kind: "class-class" }`.
|
|
/// Post-canonical-class-form the workspace loads cleanly and
|
|
/// `env.method_to_candidate_classes` carries both qualified classes as
|
|
/// candidates for the method name `foo`.
|
|
#[test]
|
|
fn mq3_class_class_collision_loads_clean_and_populates_candidates() {
|
|
let entry = examples_dir()
|
|
.join("test_22b2_method_name_collision_class_class.ail");
|
|
let ws = load_workspace(&entry)
|
|
.expect("post-canonical-class-form: workspace loads without collision diagnostic");
|
|
|
|
let env = build_check_env(&ws);
|
|
let candidates = env
|
|
.method_to_candidate_classes
|
|
.get("foo")
|
|
.expect("`foo` must be in method_to_candidate_classes");
|
|
assert!(
|
|
candidates.contains("test_22b2_method_name_collision_class_class.A"),
|
|
"candidates must include class A: {candidates:?}",
|
|
);
|
|
assert!(
|
|
candidates.contains("test_22b2_method_name_collision_class_class.B"),
|
|
"candidates must include class B: {candidates:?}",
|
|
);
|
|
assert_eq!(
|
|
candidates.len(),
|
|
2,
|
|
"exactly two candidate classes for `foo`: {candidates:?}",
|
|
);
|
|
}
|
|
|
|
/// Class-fn repurpose: the fixture
|
|
/// `examples/test_22b2_method_name_collision_class_fn.ail.json`
|
|
/// declares `class Greet { greet }` and `fn greet`. Pre-canonical-class-form this
|
|
/// fired `WorkspaceLoadError::MethodNameCollision { kind: "class-fn" }`.
|
|
/// Post-canonical-class-form the workspace loads cleanly — the method-vs-fn
|
|
/// coexistence is now legal at load time; the call-site emits a
|
|
/// `class-method-shadowed-by-fn` warning (covered by the multi-class E2E,
|
|
/// not this load-level pin).
|
|
#[test]
|
|
fn mq3_class_fn_collision_loads_clean() {
|
|
let entry = examples_dir()
|
|
.join("test_22b2_method_name_collision_class_fn.ail");
|
|
load_workspace(&entry)
|
|
.expect("post-canonical-class-form: workspace loads — class-vs-fn name overlap is no longer a load error");
|
|
}
|