Preserve raw include diagnostic provenance and derive bands from the existing shaped editor. Retain deferred tooltip paragraphs through rendering. Include source, regression, failure and native-trial evidence; corrected native acceptance remains pending.
84 lines
2.3 KiB
Rust
84 lines
2.3 KiB
Rust
use super::*;
|
|
use oa_core::{
|
|
language::{Diagnostic, Span},
|
|
validation::Severity,
|
|
};
|
|
|
|
fn diagnostic(path: &str, start: usize, end: usize) -> SourceDiagnostic {
|
|
SourceDiagnostic {
|
|
path: path.into(),
|
|
diagnostic: Diagnostic {
|
|
severity: Severity::Error,
|
|
code: "test".into(),
|
|
message: "synthetic admission fixture".into(),
|
|
object_id: None,
|
|
field: None,
|
|
line: 999,
|
|
column: 999,
|
|
span: Span { start, end },
|
|
},
|
|
related: Vec::new(),
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn exact_path_and_utf8_range_admission_keep_valid_neighbor() {
|
|
let index = Index::new(
|
|
Arc::from("雨 x"),
|
|
"a.arcadia",
|
|
&[
|
|
diagnostic("b.arcadia", 0, 3),
|
|
diagnostic("a.arcadia", 1, 3),
|
|
diagnostic("a.arcadia", 4, 2),
|
|
diagnostic("a.arcadia", 0, 99),
|
|
diagnostic("a.arcadia", 4, 5),
|
|
],
|
|
);
|
|
assert_eq!(index.parts.len(), 1);
|
|
let parts = &index.parts[&0];
|
|
assert_eq!(parts.len(), 1);
|
|
assert_eq!((parts[0].diagnostic, parts[0].bytes.clone()), (4, 4..5));
|
|
}
|
|
|
|
#[test]
|
|
fn mixed_endings_use_actual_paragraphs_and_preserve_eof() {
|
|
let index = Index::new(
|
|
Arc::from("a\r\n雨\rb\n\rc\n"),
|
|
"a",
|
|
&[
|
|
diagnostic("a", 3, 6),
|
|
diagnostic("a", 7, 8),
|
|
diagnostic("a", 12, 12),
|
|
],
|
|
);
|
|
assert_eq!(index.lines, vec![0..1, 3..6, 7..8, 10..11, 12..12]);
|
|
assert_eq!(index.parts[&1][0].bytes, 0..3);
|
|
assert_eq!(index.parts[&2][0].bytes, 0..1);
|
|
assert_eq!(index.parts[&4][0].bytes, 0..0);
|
|
}
|
|
|
|
#[test]
|
|
fn half_open_next_line_excluded_separator_only_and_empty_line_anchored() {
|
|
let index = Index::new(
|
|
Arc::from("ab\r\n\r\ncd"),
|
|
"a",
|
|
&[
|
|
diagnostic("a", 0, 4),
|
|
diagnostic("a", 2, 4),
|
|
diagnostic("a", 4, 6),
|
|
],
|
|
);
|
|
assert_eq!(index.parts.len(), 2);
|
|
assert_eq!(index.parts[&0][0].bytes, 0..2);
|
|
assert_eq!(index.parts[&0][1].bytes, 2..2);
|
|
assert_eq!(index.parts[&1][0].bytes, 0..0);
|
|
assert!(!index.parts.contains_key(&2));
|
|
}
|
|
|
|
#[test]
|
|
fn empty_source_has_real_zero_width_marker() {
|
|
let index = Index::new(Arc::from(""), "a", &[diagnostic("a", 0, 0)]);
|
|
assert_eq!(index.lines, vec![0..0]);
|
|
assert_eq!(index.parts[&0][0].bytes, 0..0);
|
|
}
|