test: retain complete mixed Project warning oracle

This commit is contained in:
2026-09-23 23:28:56 -07:00
parent b9a31bb848
commit 71cadfa0cd
@@ -166,6 +166,37 @@ fn span(source: &str, context: &str, offset: usize, len: usize) -> Span {
}
}
fn expected_leaf_work_warnings(span: Span, line: usize, column: usize) -> [SourceDiagnostic; 2] {
// Ordinary allocation validation precedes advisory behavior coverage. Both
// diagnostics fall back to the full Work declaration, with no related site.
[
(
"unallocated_leaf",
Some("allocation"),
"Allocate leaf 'Work' to a performer.",
),
(
"work_without_behavior_context",
None,
"Include this leaf activity/function in a process/chain or scenario through a work action or exchange occurrence.",
),
]
.map(|(code, field, message)| SourceDiagnostic {
path: "main.arcadia".into(),
diagnostic: language::Diagnostic {
severity: validation::Severity::Warning,
code: code.into(),
object_id: Some(id(2)),
field: field.map(str::to_owned),
line,
column,
message: message.into(),
span,
},
related: Vec::new(),
})
}
#[test]
fn complete_oa_sa_forward_model_warning_and_original_authority() {
for layer in [Layer::Oa, Layer::Sa] {
@@ -183,19 +214,6 @@ fn complete_oa_sa_forward_model_warning_and_original_authority() {
resolved.syntax.files[0].source.as_ptr(),
bundle.files["main.arcadia"].as_ptr()
));
assert_eq!(resolved.warnings().len(), 1);
let warning = &resolved.warnings()[0];
assert_eq!(
(&warning.path, warning.diagnostic.object_id),
(&bundle.entry, Some(id(2)))
);
assert_eq!(warning.diagnostic.severity, validation::Severity::Warning);
assert_eq!(warning.diagnostic.code, "unallocated_leaf");
assert_eq!(warning.diagnostic.field.as_deref(), Some("allocation"));
assert_eq!(
warning.diagnostic.message,
"Allocate leaf 'Work' to a performer."
);
let declaration = format!(
"{} w \"Work\" id \"{}\" {{}}",
if layer == Layer::Oa {
@@ -206,13 +224,19 @@ fn complete_oa_sa_forward_model_warning_and_original_authority() {
id(2)
);
assert_eq!(
warning.diagnostic.span,
span(
&bundle.files["main.arcadia"],
&declaration,
0,
declaration.len()
)
resolved.warnings(),
expected_leaf_work_warnings(
span(
&bundle.files["main.arcadia"],
&declaration,
0,
declaration.len()
),
5,
1
),
"complete {layer:?} warning oracle; actual diagnostics: {:#?}",
resolved.warnings()
);
assert_eq!(resolved.expressions.len(), 1);
assert_eq!(resolved.occurrences.len(), 1);
@@ -575,9 +599,22 @@ fn complete_static_architecture_and_unicode_warning_mapping() {
let source = bundle.files.get_mut("main.arcadia").unwrap();
*source = format!("// 雪\r\n{}", source.replace('\n', "\r\n"));
let resolved = accepted(&bundle);
let warning = &resolved.warnings()[0].diagnostic;
assert_eq!(warning.line, 6);
assert_eq!(warning.column, 1);
let declaration = format!("oa_activity w \"Work\" id \"{}\" {{}}", id(2));
assert_eq!(
resolved.warnings(),
expected_leaf_work_warnings(
span(
&bundle.files["main.arcadia"],
&declaration,
0,
declaration.len()
),
6,
1
),
"complete CRLF warning oracle; actual diagnostics: {:#?}",
resolved.warnings()
);
// Same physical line: the two header-name scalars occupy seven UTF-8
// bytes. Independently authored coordinates distinguish column60 from
// byte-column65; the warning covers the complete Work declaration.
@@ -593,19 +630,18 @@ fn complete_static_architecture_and_unicode_warning_mapping() {
)]),
};
let inline_value = accepted(&inline);
assert_eq!(inline_value.warnings().len(), 1);
let inline_warning = &inline_value.warnings()[0];
assert_eq!(inline_warning.path, "main.arcadia");
assert_eq!(inline_warning.diagnostic.code, "unallocated_leaf");
assert_eq!(inline_warning.diagnostic.object_id, Some(id(2)));
assert_eq!(inline_warning.diagnostic.line, 2);
assert_eq!(inline_warning.diagnostic.column, 60);
assert_eq!(
inline_warning.diagnostic.span,
Span {
start: 76,
end: 141
}
inline_value.warnings(),
expected_leaf_work_warnings(
Span {
start: 76,
end: 141
},
2,
60
),
"complete same-line Unicode warning oracle; actual diagnostics: {:#?}",
inline_value.warnings()
);
let mut bad = bundle.clone();
*bad.files.get_mut("main.arcadia").unwrap() =