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

Function test_case

crates/css_lexer/tests/css-tokenizer-tests.rs:216–246  ·  view source on GitHub ↗
(case: CSSTokenizerTestCase)

Source from the content-addressed store, hash-verified

214}
215
216fn test_case(case: CSSTokenizerTestCase) -> u8 {
217 dbg!(&case.name);
218 let mut lexer = Lexer::new(&EmptyAtomSet::ATOMS, &case.source_text);
219 let mut tokens = vec![];
220 loop {
221 let offset = lexer.offset();
222 let cursor = lexer.advance().with_cursor(offset);
223 if cursor.token().kind() == Kind::Eof {
224 break;
225 }
226 tokens.push(convert_token(&case.source_text, cursor));
227 }
228 if tokens != *case.desired {
229 let left: String = to_string_pretty(&tokens).unwrap_or("".to_string());
230 let right: String = to_string_pretty(&case.desired).unwrap_or("".to_string());
231 println!("{} {}", Style::new().red().apply_to("✘ FAILED"), case.name);
232 println!("{}", Style::new().red().apply_to("- actual"));
233 println!("{}", Style::new().green().apply_to("+ expected"));
234 let diff = TextDiff::from_lines(&*left, &*right);
235 for change in diff.iter_all_changes() {
236 let (sign, style) = match change.tag() {
237 ChangeTag::Delete => ("-", Style::new().red()),
238 ChangeTag::Insert => ("+", Style::new().green()),
239 ChangeTag::Equal => (" ", Style::new()),
240 };
241 print!("{}{}", style.apply_to(sign).bold(), style.apply_to(change));
242 }
243 return 1;
244 }
245 0
246}
247
248#[test]
249fn full_suite() {

Callers 1

full_suiteFunction · 0.70

Calls 6

convert_tokenFunction · 0.85
with_cursorMethod · 0.80
advanceMethod · 0.80
offsetMethod · 0.45
kindMethod · 0.45
tokenMethod · 0.45

Tested by

no test coverage detected