()
| 878 | |
| 879 | #[test] |
| 880 | fn test_temp_scope() -> Result<()> { |
| 881 | let upcalls = HashMap::default(); |
| 882 | let mut global = GlobalSymtable::new(upcalls); |
| 883 | let mut local = global.enter_scope(); |
| 884 | assert_eq!( |
| 885 | Register::local(0).unwrap(), |
| 886 | local.put_local(SymbolKey::from("foo"), SymbolPrototype::Scalar(ExprType::Integer))? |
| 887 | ); |
| 888 | { |
| 889 | let temp = local.frozen(); |
| 890 | { |
| 891 | let mut scope = temp.temp_scope(); |
| 892 | assert_eq!(Register::local(1).unwrap(), scope.alloc()?); |
| 893 | { |
| 894 | let mut scope = temp.temp_scope(); |
| 895 | assert_eq!(Register::local(2).unwrap(), scope.alloc()?); |
| 896 | assert_eq!(Register::local(3).unwrap(), scope.alloc()?); |
| 897 | assert_eq!(Register::local(4).unwrap(), scope.alloc()?); |
| 898 | } |
| 899 | { |
| 900 | let mut scope = temp.temp_scope(); |
| 901 | assert_eq!(Register::local(2).unwrap(), scope.alloc()?); |
| 902 | assert_eq!(Register::local(3).unwrap(), scope.alloc()?); |
| 903 | } |
| 904 | assert_eq!(Register::local(2).unwrap(), scope.alloc()?); |
| 905 | } |
| 906 | } |
| 907 | { |
| 908 | let temp = local.frozen(); |
| 909 | { |
| 910 | let mut scope = temp.temp_scope(); |
| 911 | assert_eq!(Register::local(1).unwrap(), scope.alloc()?); |
| 912 | } |
| 913 | } |
| 914 | Ok(()) |
| 915 | } |
| 916 | |
| 917 | #[test] |
| 918 | fn test_with_reserved_temp_register_index() -> Result<()> { |
nothing calls this directly
no test coverage detected