Commit d92628de authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[tests] Use mock arraybuffer allocator in test to avoid huge allocation.

This sometimes caused problems with bots (for node too) because the
allocation could fail.

Bug: v8:6452
Change-Id: I346a9117eba8b6ed41566efeceaf7fb190784d76
Reviewed-on: https://chromium-review.googlesource.com/558075Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46373}
parent 9e7b928f
......@@ -2,18 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
// Flags: --allow-natives-syntax --mock-arraybuffer-allocator
(function TestBufferByteLengthNonSmi() {
var non_smi_byte_length = %_MaxSmi() + 1;
try {
var buffer = new ArrayBuffer(non_smi_byte_length);
} catch (e) {
// The ArrayBuffer allocation can fail on 32-bit archs, so no need to try to
// construct the typed array.
return;
}
var arr = new Uint16Array(buffer);
assertEquals(non_smi_byte_length, arr.byteLength);
......@@ -26,33 +21,17 @@
(function TestByteOffsetNonSmi() {
var non_smi_byte_length = %_MaxSmi() + 11;
try {
var buffer = new ArrayBuffer(non_smi_byte_length);
} catch (e) {
// The ArrayBuffer allocation can fail on 32-bit archs, so no need to try to
// construct the typed array.
return;
}
print(buffer.byteLength);
var whole = new Uint16Array(buffer);
whole[non_smi_byte_length / 2 - 1] = 1;
whole[non_smi_byte_length / 2 - 2] = 2;
whole[non_smi_byte_length / 2 - 3] = 3;
whole[non_smi_byte_length / 2 - 4] = 4;
whole[non_smi_byte_length / 2 - 5] = 5;
assertEquals(non_smi_byte_length, whole.byteLength);
assertEquals(non_smi_byte_length / 2, whole.length);
assertEquals(1, whole[non_smi_byte_length / 2 - 1]);
var arr = new Uint16Array(buffer, non_smi_byte_length - 10, 5);
assertEquals(non_smi_byte_length, arr.buffer.byteLength);
assertEquals(10, arr.byteLength);
assertEquals(5, arr.length);
assertEquals(5, arr[0]);
assertEquals(4, arr[1]);
assertEquals(3, arr[2]);
assertEquals(2, arr[3]);
assertEquals(1, arr[4]);
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment