()
| 644 | // single function at a time--we need more than one function in the store for this test. |
| 645 | #[test] |
| 646 | fn function_references() { |
| 647 | let code = " |
| 648 | function %child(i32) -> i32 { |
| 649 | block0(v0: i32): |
| 650 | v2 = iconst.i32 -1 |
| 651 | v1 = iadd v0, v2 |
| 652 | return v1 |
| 653 | } |
| 654 | |
| 655 | function %parent(i32) -> i32 { |
| 656 | fn42 = %child(i32) -> i32 |
| 657 | block0(v0: i32): |
| 658 | v3 = iconst.i32 1 |
| 659 | v1 = iadd v0, v3 |
| 660 | v2 = call fn42(v1) |
| 661 | return v2 |
| 662 | }"; |
| 663 | |
| 664 | let mut env = FunctionStore::default(); |
| 665 | let funcs = parse_functions(code).unwrap().to_vec(); |
| 666 | funcs.iter().for_each(|f| env.add(f.name.to_string(), f)); |
| 667 | |
| 668 | let state = InterpreterState::default().with_function_store(env); |
| 669 | let result = Interpreter::new(state) |
| 670 | .call_by_name("%parent", &[DataValue::I32(0)]) |
| 671 | .unwrap(); |
| 672 | |
| 673 | assert_eq!(result, ControlFlow::Return(smallvec![DataValue::I32(0)])); |
| 674 | } |
| 675 | |
| 676 | #[test] |
| 677 | fn fuel() { |
nothing calls this directly
no test coverage detected