()
| 843 | |
| 844 | #[test] |
| 845 | fn nop() { |
| 846 | // Skip this test when cranelift doesn't support the native platform. |
| 847 | if cranelift_native::builder().is_err() { |
| 848 | return; |
| 849 | } |
| 850 | let code = String::from( |
| 851 | " |
| 852 | test run |
| 853 | function %test() -> i8 { |
| 854 | block0: |
| 855 | nop |
| 856 | v1 = iconst.i8 -1 |
| 857 | return v1 |
| 858 | }", |
| 859 | ); |
| 860 | let ctrl_plane = &mut ControlPlane::default(); |
| 861 | |
| 862 | // extract function |
| 863 | let test_file = parse_test(code.as_str(), ParseOptions::default()).unwrap(); |
| 864 | assert_eq!(1, test_file.functions.len()); |
| 865 | let function = test_file.functions[0].0.clone(); |
| 866 | |
| 867 | // execute function |
| 868 | let mut compiler = TestFileCompiler::with_default_host_isa().unwrap(); |
| 869 | compiler.declare_function(&function).unwrap(); |
| 870 | compiler |
| 871 | .define_function(function.clone(), ctrl_plane) |
| 872 | .unwrap(); |
| 873 | compiler |
| 874 | .create_trampoline_for_function(&function, ctrl_plane) |
| 875 | .unwrap(); |
| 876 | let compiled = compiler.compile().unwrap(); |
| 877 | let trampoline = compiled.get_trampoline(&function).unwrap(); |
| 878 | let returned = trampoline.call(&compiled, &[]); |
| 879 | assert_eq!(returned, vec![DataValue::I8(-1)]) |
| 880 | } |
| 881 | |
| 882 | #[test] |
| 883 | fn trampolines() { |
nothing calls this directly
no test coverage detected