()
| 630 | |
| 631 | #[test] |
| 632 | fn basic() { |
| 633 | let mut f = Function::new(); |
| 634 | assert_eq!(f.to_string(), "function u0:0() fast {\n}\n"); |
| 635 | |
| 636 | f.name = UserFuncName::testcase("foo"); |
| 637 | assert_eq!(f.to_string(), "function %foo() fast {\n}\n"); |
| 638 | |
| 639 | f.create_sized_stack_slot(StackSlotData::new(StackSlotKind::ExplicitSlot, 4, 0)); |
| 640 | assert_eq!( |
| 641 | f.to_string(), |
| 642 | "function %foo() fast {\n ss0 = explicit_slot 4\n}\n" |
| 643 | ); |
| 644 | |
| 645 | let block = f.dfg.make_block(); |
| 646 | f.layout.append_block(block); |
| 647 | assert_eq!( |
| 648 | f.to_string(), |
| 649 | "function %foo() fast {\n ss0 = explicit_slot 4\n\nblock0:\n}\n" |
| 650 | ); |
| 651 | |
| 652 | f.dfg.append_block_param(block, types::I8); |
| 653 | assert_eq!( |
| 654 | f.to_string(), |
| 655 | "function %foo() fast {\n ss0 = explicit_slot 4\n\nblock0(v0: i8):\n}\n" |
| 656 | ); |
| 657 | |
| 658 | f.dfg.append_block_param(block, types::F32.by(4).unwrap()); |
| 659 | assert_eq!( |
| 660 | f.to_string(), |
| 661 | "function %foo() fast {\n ss0 = explicit_slot 4\n\nblock0(v0: i8, v1: f32x4):\n}\n" |
| 662 | ); |
| 663 | |
| 664 | { |
| 665 | let mut cursor = FuncCursor::new(&mut f); |
| 666 | cursor.set_position(CursorPosition::After(block)); |
| 667 | cursor.ins().return_(&[]) |
| 668 | }; |
| 669 | assert_eq!( |
| 670 | f.to_string(), |
| 671 | "function %foo() fast {\n ss0 = explicit_slot 4\n\nblock0(v0: i8, v1: f32x4):\n return\n}\n" |
| 672 | ); |
| 673 | |
| 674 | let mut f = Function::new(); |
| 675 | f.create_sized_stack_slot(StackSlotData::new(StackSlotKind::ExplicitSlot, 4, 2)); |
| 676 | assert_eq!( |
| 677 | f.to_string(), |
| 678 | "function u0:0() fast {\n ss0 = explicit_slot 4, align = 4\n}\n" |
| 679 | ); |
| 680 | } |
| 681 | |
| 682 | #[test] |
| 683 | fn aliases() { |
nothing calls this directly
no test coverage detected