-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmemory.test.ts
More file actions
42 lines (34 loc) · 1.44 KB
/
memory.test.ts
File metadata and controls
42 lines (34 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {expect, use} from '@esm-bundle/chai';
import {chaiAlmost} from './chai/almost.js';
import {init, reset, WL} from './setup.js';
use(chaiAlmost());
before(init);
beforeEach(reset);
describe('Memory', function () {
let ptr: number | null = null;
after(function () {
if (ptr !== null) WL.wasm._free(ptr);
});
it('grow memory, ensure views are updated', async function () {
const oldHEAP8 = WL.wasm.HEAP8;
const oldHEAP16 = WL.wasm.HEAP16;
const oldHEAP32 = WL.wasm.HEAP32;
const oldHEAPU8 = WL.wasm.HEAPU8;
const oldHEAPU16 = WL.wasm.HEAPU16;
const oldHEAPU32 = WL.wasm.HEAPU32;
const oldHEAPF32 = WL.wasm.HEAPF32;
const oldHEAPF64 = WL.wasm.HEAPF64;
/* Allocate 24 MB to grow beyond the 24 initial MB
* This should never fail with out of memory. If it does,
* read the error closely, it could fail in our updateMemoryViews() */
ptr = WL.wasm._malloc(1024 * 1024 * 24);
expect(oldHEAP8 == WL.wasm.HEAP8).to.be.false;
expect(oldHEAP16 == WL.wasm.HEAP16).to.be.false;
expect(oldHEAP32 == WL.wasm.HEAP32).to.be.false;
expect(oldHEAPU8 == WL.wasm.HEAPU8).to.be.false;
expect(oldHEAPU16 == WL.wasm.HEAPU16).to.be.false;
expect(oldHEAPU32 == WL.wasm.HEAPU32).to.be.false;
expect(oldHEAPF32 == WL.wasm.HEAPF32).to.be.false;
expect(oldHEAPF64 == WL.wasm.HEAPF64).to.be.false;
});
});