Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Added an integration test for array buffer zero initialization.
Browse files Browse the repository at this point in the history
This would have caught the bug fixed by ce4ced9, at least on my system.
  • Loading branch information
jacobsa committed Nov 2, 2014
1 parent ce4ced9 commit 2d057a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gjstest/internal/integration_tests/typed_arrays.golden.txt
Expand Up @@ -33,6 +33,8 @@
[ OK ] TypedArraysTest.ArrayBufferContructorErrors (1 ms)
[ RUN ] TypedArraysTest.TypedArrayContructorErrors
[ OK ] TypedArraysTest.TypedArrayContructorErrors (1 ms)
[ RUN ] TypedArraysTest.ZeroInitialization
[ OK ] TypedArraysTest.ZeroInitialization (1 ms)
[----------]

[ PASSED ]
1 change: 1 addition & 0 deletions gjstest/internal/integration_tests/typed_arrays.golden.xml
Expand Up @@ -17,4 +17,5 @@
<testcase name="TypedArraysTest.ConstructFromOtherTypedArray" time="0.01"/>
<testcase name="TypedArraysTest.ArrayBufferContructorErrors" time="0.01"/>
<testcase name="TypedArraysTest.TypedArrayContructorErrors" time="0.01"/>
<testcase name="TypedArraysTest.ZeroInitialization" time="0.01"/>
</testsuite>
17 changes: 17 additions & 0 deletions gjstest/internal/integration_tests/typed_arrays_test.js
Expand Up @@ -1041,3 +1041,20 @@ TypedArraysTest.prototype.TypedArrayContructorErrors = function() {
} catch (e) {
}
};

TypedArraysTest.prototype.ZeroInitialization = function() {
// Created via array buffer.
var buffer = new ArrayBuffer(8192);
var bytes = new Uint8Array(buffer);

for (var i = 0; i < bytes.length; ++i) {
expectEq(0, bytes[i]);
}

// Created directly.
bytes = new Uint8Array(8192);

for (var i = 0; i < bytes.length; ++i) {
expectEq(0, bytes[i]);
}
};

0 comments on commit 2d057a2

Please sign in to comment.