MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / adding_arms_works

Function adding_arms_works

cranelift/srcgen/src/lib.rs:398–426  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

396
397 #[test]
398 fn adding_arms_works() {
399 let mut m = Match::new("x");
400 m.arm("Orange", vec!["a", "b"], "some body");
401 m.arm("Yellow", vec!["a", "b"], "some body");
402 m.arm("Green", vec!["a", "b"], "different body");
403 m.arm("Blue", vec!["x", "y"], "some body");
404 assert_eq!(m.arms.len(), 3);
405
406 let mut fmt = Formatter::new(Language::Rust);
407 fmt.add_match(m);
408
409 let expected_lines = from_raw_string(
410 r#"
411match x {
412 Green { a, b } => {
413 different body
414 }
415 Orange { a, b } |
416 Yellow { a, b } => {
417 some body
418 }
419 Blue { x, y } => {
420 some body
421 }
422}
423 "#,
424 );
425 assert_eq!(fmt.lines, expected_lines);
426 }
427
428 #[test]
429 fn match_with_catchall_order() {

Callers

nothing calls this directly

Calls 4

from_raw_stringFunction · 0.85
armMethod · 0.80
add_matchMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected