MCPcopy Create free account
hub / github.com/csskit/csskit / test_gap_filling

Function test_gap_filling

crates/css_parse/src/cursor_ordered_sink.rs:211–231  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

209
210 #[test]
211 fn test_gap_filling() {
212 use crate::{SourceOffset, Token};
213 let bump = Bump::default();
214 let mut output = BumpVec::new_in(&bump);
215
216 {
217 let mut ordered_sink = CursorOrderedSink::new(&bump, &mut output);
218 // Create cursors with a gap, then fill the gap
219 let cursor_at_0 = Cursor::new(SourceOffset(0), Token::SPACE); // ends at 1
220 let cursor_at_2 = Cursor::new(SourceOffset(2), Token::SPACE); // ends at 3
221 let cursor_at_1 = Cursor::new(SourceOffset(1), Token::SPACE); // ends at 2, fills the gap
222 ordered_sink.append(cursor_at_0);
223 ordered_sink.append(cursor_at_2);
224 ordered_sink.append(cursor_at_1);
225 // Avoid flushing as they should be emitted immediately
226 }
227 assert_eq!(output.len(), 3);
228 assert_eq!(output[0].span().start(), SourceOffset(0));
229 assert_eq!(output[1].span().start(), SourceOffset(1));
230 assert_eq!(output[2].span().start(), SourceOffset(2));
231 }
232
233 #[test]
234 fn test_sequential() {

Callers

nothing calls this directly

Calls 2

SourceOffsetClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected