()
| 3174 | |
| 3175 | #[test] |
| 3176 | fn stack_slot_decl() { |
| 3177 | let (func, _) = Parser::new( |
| 3178 | "function %foo() system_v { |
| 3179 | ss3 = explicit_slot 13 |
| 3180 | ss1 = explicit_slot 1 |
| 3181 | }", |
| 3182 | ) |
| 3183 | .parse_function() |
| 3184 | .unwrap(); |
| 3185 | assert_eq!(func.name.to_string(), "%foo"); |
| 3186 | let mut iter = func.sized_stack_slots.keys(); |
| 3187 | let _ss0 = iter.next().unwrap(); |
| 3188 | let ss1 = iter.next().unwrap(); |
| 3189 | assert_eq!(ss1.to_string(), "ss1"); |
| 3190 | assert_eq!( |
| 3191 | func.sized_stack_slots[ss1].kind, |
| 3192 | StackSlotKind::ExplicitSlot |
| 3193 | ); |
| 3194 | assert_eq!(func.sized_stack_slots[ss1].size, 1); |
| 3195 | let _ss2 = iter.next().unwrap(); |
| 3196 | let ss3 = iter.next().unwrap(); |
| 3197 | assert_eq!(ss3.to_string(), "ss3"); |
| 3198 | assert_eq!( |
| 3199 | func.sized_stack_slots[ss3].kind, |
| 3200 | StackSlotKind::ExplicitSlot |
| 3201 | ); |
| 3202 | assert_eq!(func.sized_stack_slots[ss3].size, 13); |
| 3203 | assert_eq!(iter.next(), None); |
| 3204 | |
| 3205 | // Catch duplicate definitions. |
| 3206 | assert_eq!( |
| 3207 | Parser::new( |
| 3208 | "function %bar() system_v { |
| 3209 | ss1 = explicit_slot 13 |
| 3210 | ss1 = explicit_slot 1 |
| 3211 | }", |
| 3212 | ) |
| 3213 | .parse_function() |
| 3214 | .unwrap_err() |
| 3215 | .to_string(), |
| 3216 | "3: duplicate entity: ss1" |
| 3217 | ); |
| 3218 | } |
| 3219 | |
| 3220 | #[test] |
| 3221 | fn block_header() { |
nothing calls this directly
no test coverage detected