()
| 341 | // each needle below is a representative token some example must demonstrate. |
| 342 | #[test] |
| 343 | fn examples_cover_core_features() { |
| 344 | use full_stack::program_catalog::{ProgramCatalog, ProgramKind}; |
| 345 | let catalog = ProgramCatalog::default(); |
| 346 | let combined = catalog |
| 347 | .get_programs_by_kind(ProgramKind::Example) |
| 348 | .iter() |
| 349 | .map(|p| p.source.as_str()) |
| 350 | .collect::<Vec<_>>() |
| 351 | .join("\n"); |
| 352 | |
| 353 | let needles = [ |
| 354 | (":=", "inferred declaration"), |
| 355 | ("const ", "compile-time constant"), |
| 356 | (" as ", "cast"), |
| 357 | ("+=", "compound assignment"), |
| 358 | ("@", "whole-pointee dereference"), |
| 359 | ("&", "address-of"), |
| 360 | ("new(", "heap allocation"), |
| 361 | ("defer ", "deferred cleanup"), |
| 362 | ("struct ", "struct declaration"), |
| 363 | (".len", "slice length"), |
| 364 | ("[..]", "array-to-slice coercion"), |
| 365 | ("..=", "inclusive range"), |
| 366 | ("for ", "for loop"), |
| 367 | ("enum ", "enum declaration"), |
| 368 | ("match ", "match expression"), |
| 369 | ("Option", "Option carrier"), |
| 370 | ("Result", "Result carrier"), |
| 371 | ("?", "try propagation"), |
| 372 | ("<i32>", "generic specialization"), |
| 373 | ("(i32, i32) -> i32", "function pointer type"), |
| 374 | ("'A'", "character literal"), |
| 375 | ]; |
| 376 | |
| 377 | for (needle, feature) in needles { |
| 378 | assert!( |
| 379 | combined.contains(needle), |
| 380 | "no launchable example demonstrates {feature} (missing token `{needle}`)" |
| 381 | ); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | #[test] |
| 386 | fn allows_newline_separated_struct_fields() { |
nothing calls this directly
no test coverage detected