mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-16 05:59:21 +03:00
450c9234ad
This is useful for debugging and writing tests that assert various operations do not leak `JsValue`s.
21 lines
650 B
Rust
21 lines
650 B
Rust
use wasm_bindgen::prelude::*;
|
|
use wasm_bindgen_test::*;
|
|
|
|
// This test is in the headless suite so that we can test the `anyref` table
|
|
// implementation of `anyref_heap_live_count` (as opposed to the JS `heap`
|
|
// implementation) in Firefox.
|
|
#[wasm_bindgen_test]
|
|
fn test_anyref_heap_live_count() {
|
|
let initial = wasm_bindgen::anyref_heap_live_count();
|
|
|
|
let after_alloc = {
|
|
let _vals: Vec<_> = (0..10).map(JsValue::from).collect();
|
|
wasm_bindgen::anyref_heap_live_count()
|
|
};
|
|
|
|
let after_dealloc = wasm_bindgen::anyref_heap_live_count();
|
|
|
|
assert_eq!(initial, after_dealloc);
|
|
assert_eq!(initial + 10, after_alloc);
|
|
}
|