-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14759c1
commit abab453
Showing
2 changed files
with
54 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Heap } from '@glimmer/program'; | ||
|
||
QUnit.module('Heap'); | ||
|
||
QUnit.test('Can grow', (assert) => { | ||
let size = 0x100000; | ||
let heap = new Heap(); | ||
|
||
let i = 0; | ||
|
||
while (i !== (size - 1)) { | ||
heap.push(1); | ||
i++; | ||
} | ||
|
||
// Should grow here | ||
heap.push(10); | ||
|
||
// Slices the buffer. Passing MAX_SAFE_INTEGER ensures | ||
// we get the whole thing out | ||
let serialized = heap.capture(Number.MAX_SAFE_INTEGER); | ||
let serializedHeap = new Uint16Array(serialized.buffer); | ||
assert.equal(serializedHeap.length, size * 2); | ||
assert.equal(serializedHeap[size - 1], 10); | ||
|
||
heap.push(11); | ||
|
||
serialized = heap.capture(Number.MAX_SAFE_INTEGER); | ||
serializedHeap = new Uint16Array(serialized.buffer); | ||
assert.equal(serializedHeap.length, size * 2); | ||
assert.equal(serializedHeap[size], 11); | ||
}); |