| 238 | assert_eq!(exit, Some(0)); |
| 239 | } |
| 240 | |
| 241 | #[test] |
| 242 | fn hosted_fallible_allocator_aligns_and_preserves_reallocated_bytes() { |
| 243 | let (_, exit) = run_hll( |
| 244 | r#" |
| 245 | alloc := import("alloc") |
| 246 | vec := import("vec") |
| 247 | owned := import("owned_string") |
| 248 | arena := import("arena") |
| 249 | pool := import("pool") |
| 250 | |
| 251 | main: () -> i32 { |
| 252 | ptr: u8* = 0 as u8* |
| 253 | first := alloc.allocate(5, 64) |
| 254 | match first { |
| 255 | Ok(value) -> { ptr = value } |
| 256 | Err(error) -> { return 1 } |
| 257 | } |
| 258 | if (ptr as u64) % 64 != 0 { return 2 } |
| 259 | ptr[0] = 17 |
| 260 | ptr[4] = 93 |
| 261 | |
| 262 | grown: u8* = 0 as u8* |
| 263 | resized := alloc.reallocate(ptr, 5, 19, 64) |