| 1 |
use wasm_bindgen::prelude::*; |
| 2 |
use wasm_bindgen_test::*; |
| 3 |
|
| 4 |
// This test is in the headless suite so that we can test the `externref` table |
| 5 |
// implementation of `externref_heap_live_count` (as opposed to the JS `heap` |
| 6 |
// implementation) in Firefox. |
| 7 |
#[wasm_bindgen_test] |
| 8 |
fn test_externref_heap_live_count() { |
| 9 |
let initial = wasm_bindgen::externref_heap_live_count(); |
| 10 |
|
| 11 |
let after_alloc = { |
| 12 |
let _vals: Vec<_> = (0..10).map(JsValue::from).collect(); |
| 13 |
wasm_bindgen::externref_heap_live_count() |
| 14 |
}; |
| 15 |
|
| 16 |
let after_dealloc = wasm_bindgen::externref_heap_live_count(); |
| 17 |
|
| 18 |
assert_eq!(initial, after_dealloc); |
| 19 |
assert_eq!(initial + 10, after_alloc); |
| 20 |
} |